Ionic location get cached position


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: ="map").fitWorld();
	    leaflet.tileLayer('https://{s}{z}/{x}/{y}.png', {
	      //attribution: 'Map data &copy; <a href="">OpenStreetMap</a> contributors, <a href="">CC-BY-SA</a>, Imagery © <a href="">Mapbox</a>',
	      attribution: 'Map data &copy; <a href="">OpenStreetMap</a> contributors, <a href="">CC-BY-SA</a>',
	      maxZoom: 18,
	      draggable: true
	      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 =;
	        this.ubi_lat =;
	      	this.ubi_long = chagedPos.lng;
	      }).on('locationerror', (err) => {

What I can do? The “maximunAge” property doesn’t work… Any help? Thanks


Please refer this coding its must work,but you can import plugins in geolocation,geocoder.Then import app.module.ts file,then where you want to use this coding copy and paste it.

//get location coding this file you can paste it.
import { NativeGeocoder, NativeGeocoderReverseResult, NativeGeocoderOptions } from ‘@ionic-native/native-geocoder’;

selector: ‘page-register’,
templateUrl: ‘register.html’,
export class RegisterPage {
//declare the variable
data:any = {};
public deviceInfo: deviceInterface = {};
loading: any;
public lat:number;
public lng:number;

//parameters are used to geolocation.
constructer(public nativeGeocoder: NativeGeocoder,public geolocation: Geolocation){
//Get a location
this.geolocation.getCurrentPosition({enableHighAccuracy: true}).then((resp) => { resp.coords.latitude;
this.lng= resp.coords.longitude;
}).catch((error) => {
console.log(‘Error getting location’, error);

//lat and lng conversion of original address.
let options: NativeGeocoderOptions = {
useLocale: false,
maxResults: 2
.then((result: NativeGeocoderReverseResult) =>{ result[1].subLocality +","+ result[1].locality +","+
result[1].subAdministrativeArea +","+ result[1].administrativeArea +"-"+
result[1].postalCode +","+result[1].countryName;
}).catch((error: any) => console.log(error));
its work correctly,please refer this coding,try it.