Hello,
I’m using Leaflet for maps and for geolocate, but when I move to another location the app returns the old location. This is my code:
this.map = leaflet.map("map").fitWorld();
leaflet.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
//attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
maxZoom: 18,
draggable: true
}).addTo(this.map);
this.map.locate({
setView: true,
maxZoom: 18,
timeout: 1000,
enableHighAccuracy: true,
maximumAge: 3600
}).on('locationfound', (e) => {
let markerGroup = leaflet.featureGroup();
this.ubi_lat = e.latitude;
this.ubi_long = e.longitude;
let marker: any = leaflet.marker([e.latitude, e.longitude], {draggable: true}).on('dragend', (ev) => {
var chagedPos = ev.target.getLatLng();
this.ubi_lat = chagedPos.lat;
this.ubi_long = chagedPos.lng;
})
markerGroup.addLayer(marker);
this.map.setZoom(16);
this.map.addLayer(markerGroup);
}).on('locationerror', (err) => {
alert(err.message);
})
What I can do? The “maximunAge” property doesn’t work… Any help? Thanks