I am developing a web application in JS or I use the map google, I have documented on all the page of https://developers.google.com/maps/documentation/javascript/examples/map- Geolocation? Hl = fr and others. But impossible to find a constant tracking. Here is my current code I did in JS:
<script type="text/javascript">
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 40.674, lng: -73.945},
zoom: 19,
scrollwheel: false,
zoomControl: false,
disableDoubleClickZoom: true,
disableDefaultUI: true,
draggable: false,
});
var image = 'https://image.noelshack.com/fichiers/2017/20/1494853817-
rond.png';
//geolocation
if (navigator.geolocation) {
setInterval(function(){
navigator.geolocation.getCurrentPosition(function(position) {
var pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
var infoWindow = new google.maps.Marker({
position: pos,
map: map,
icon: image,
});
infoWindow.setPosition(pos);
map.setCenter(pos);
},
function() {
handleLocationError(true, infoWindow, map.getCenter());
});
}, 1000);
} 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.');
}