basically I want to get current location of mobile web browser or PC web browser… but NOT onload but AFTER PRESS SHOW MY LOCATION Button,… how do this???
the below trigger with a checkbox is correct? show along another location …
function initMap() {
// Try HTML5 geolocation.
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
var latlong = new google.maps.LatLng(pos.lat,pos.lng);
var title = "You are here!";
var content = "You are here!";
var mapOptions = {
center: latlong,
panControl: false,
zoomControl: true,
zoom: 14,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map=null;
map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
var latlongPositionCustom = new google.maps.LatLng(positionCustom.latitude,positionCustom.longitude);
addMarker2(map, latlongPositionCustom, positionCustom.place, positionCustom.place); // red marker
addMarker(map, latlong, title, content); // green
}, function() {
handleLocationError(true, infoWindow, map.getCenter());
});
} else {
// Browser doesn't support Geolocation
handleLocationError(false, infoWindow, map.getCenter());
}
}
function handleLocationError(browserHasGeolocation, infoWindow, pos) {
infoWindow.setPosition(pos);
infoWindow.setContent(browserHasGeolocation ?
'Error: The Geolocation service failed.' :
'Error: Your browser doesn\'t support geolocation.');
}