@luisfernando-rf apologies for taking time to respond. I had to remove quite a bit of my other logic that I had in place and is not relevant. Let me know if you need assistance with the below, hopefully it would be self explanatory.
//declare before constructor locationLastUpdateTime = null locationMinUpdateFrequency = 5 * 1000 //~5s between user location updates private watchLocation; myPositionMarker = null; toggleLocationTrace() { try { this.watchLocation = this.geolocation.watchPosition(options) .filter((p) => p.coords !== undefined) //Filter Out Errors .subscribe(position => { console.log('position::', position, 'L:', position.coords.longitude + ' ' + position.coords.latitude); //only continue if its time to check let now = new Date(); let duration: number try { duration = now.getTime() - this.locationLastUpdateTime.getTime() } catch (error) { duration = 999999999 } if (this.locationLastUpdateTime == null || duration >= this.locationMinUpdateFrequency) { console.log('update is needed.::', duration) let newPosition = { lat: position.coords.latitude, lng: position.coords.longitude } if (this.myPositionMarker !== null) { this.myPositionMarker.setPosition(newPosition); if (this.followUserPosition == true) { this.map.moveCamera({ target: newPosition, //'zoom': 18, //'bearing': 140 }); } } else { //create the marker this.map.addMarker( { icon: 'red', title: 'me', //animation: google.maps.Animation.DROP, draggable: false, position: newPosition }) .then(marker => { this.myPositionMarker = marker console.log('my marker::', this.myPositionMarker) }); } this.locationLastUpdateTime = now; } else { //console.log('ignore position update::', duration); } }); } catch (error) { console.log('unable to watch current location::', error) } } [ Full content available at: https://github.com/apache/cordova-plugin-geolocation/issues/115 ] This message was relayed via gitbox.apache.org for devnull@infra.apache.org