Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Real-Time geolocation ionic

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); 
  });
};
like image 510
Houssem Avatar asked Jul 29 '26 11:07

Houssem


1 Answers

Please read the Leaflet reference documentation, which documents the watch option of locate(), that will do this.

like image 62
tmcw Avatar answered Aug 01 '26 03:08

tmcw