I want to build mobile app with ionic, first the user is geolocated i want to update his position every 2 seconds this is the code for the geolocation
$scope.makeFit = function() {
leafletData.getMap().then(function(map) {
map.locate({setView: true, maxZoom: 16});
var marker;
function onLocationFound(e) {
marker= new L.Marker(e.latlng);
marker.addTo(map)
.bindPopup("" + e.latlng + " ");
}
map.on('locationfound', onLocationFound);
});
};
Please read the Leaflet reference documentation, which documents the watch option of locate(), that will do this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With