I'm having a problem with navigator, I'm trying to get it to refresh the map and I can get and check the user move update for the map, but I have no idea, I thought about using a reload map function, however reloading it all and getting information from the array can demand time, battery and internet connection. Does anyone have a clue how to do this and avoid / send error images to the user when the same deny the location? OBs I already have a database, however I do not know how to put 2 active users on the map showing for everyone.
function Geolocation(){
if(window.navigator.geolocation){
// função criada para pegar localização
var array = [];
window.navigator.geolocation.watchPosition(function(position, options, accuracy) {
array = [];
var lat = position.coords.latitude;
var lon = position.coords.longitude;
var vel = position.coords.speed;
var accuracy = position.coords.accuracy;
array.push(lat, lon, vel);
console.log(array);
window.latitude = array[0];
window.longitude = array[1];
window.velocidade = array[2];
});
} }
function initMap(){
//Opções do mapa
var options = {
minZoom:16,
maxZoom:18,
zoom:17,
zoomControl: false,
scaleControl: false,
fullscreenControl: false,
streetViewControl: false,
panControl: false,
signInControl: false,
mapTypeControl: false,
noClear: true,
disableDefaultUI: false,
// center:{lat:-24.1688528,lng:-46.7855251}
center:{lat:window.latitude, lng:window.longitude}
};
//Mapa
var map = new google.maps.Map(document.getElementById('mapa'), options);
//Marcação
var marker = new google.maps.Marker({
position:{lat:window.latitude,lng:window.longitude},
// position:{lat:-24.1688528,lng:-46.7855251},
map: map,
icon: 'img/pinpoint.png'
});
}