Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49229

Ionic location get cached position

$
0
0

@fabriccio wrote:

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 &copy; <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 &copy; <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

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49229

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>