1) Create one javascript function which will return current position in Latitude and Longitude.
2) Call this function on click of button
3) After getting position you can call the function
getGeoLocation
with position
var map, infoWindow;
infoWindow = new google.maps.InfoWindow;
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var Lat = position.coords.latitude,
var Long = position.coords.longitude
getGeoLocation(Lat,Long)
}, function() {
});
} else {
}
}
function getGeoLocation(_lat,_long){
var map;
var latitude = _lat;
var longitude = _long;