I'm programming a site to get the user's location in real time, however I have 3 problems:
- accuracy
- permission to use the location (I do not know what event it takes when the user allows you to use your location or deny it, I can not work on it)
- Markers in Google Maps, if I leave a loop to pick up the user's location, I need to leave the marker in there and simply multiply the markers too.
setTimeout(function(){initMap();}, 500);
if('geolocation' in navigator){
var mapa;
function initMap() {
window.myLatLng;
function getPosition(){
markers = [];
navigator.geolocation.getCurrentPosition(function(position, accuracy){
var lat = position.coords.latitude;
var lng = position.coords.longitude;
var accuracy = position.coords.accuracy;
myLatLng = {lat: lat, lng: lng};
mapa.setCenter({lat:window.myLatLng.lat, lng:window.myLatLng.lng});
// marker.setMap(mapa);
});
}
setInterval(function(){
getPosition();
}, 500);
x = 35;
y = 139;
setTimeout(function(){
mapa = new google.maps.Map(document.getElementById('mapa'), {
center: {lat:window.myLatLng.lat, lng:window.myLatLng.lng},
minZoom:16,
maxZoom:18,
zoom:17,
zoomControl: false,
scaleControl: false,
fullscreenControl: false,
streetViewControl: false,
panControl: false,
signInControl: false,
mapTypeControl: false,
noClear: true,
disableDefaultUI: false
});
}, 1000);
}
}else{
alert('Seu navegador não possui suporte');
}