Я новичок в ионной и только что исправленной геолокации в моем приложении.Теперь я могу видеть свою позицию на карте, но у меня проблема с позицией, которая не обновляется на карте.Я перепробовал все возможные способы и много гуглил, а также читал здесь, на Stackoverflow, но все еще ничего не работает.Положение не обновляется.Можете ли вы взглянуть на мой код и сказать, что я сделал не так?
loadMap() {
this.geolocation.getCurrentPosition().then((position) => {
let latLng = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
let mapOptions = {
center: latLng,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);
//Red pin shows users position on the map
var myPositionMarker = new google.maps.Marker({
map: this.map,
position: latLng,
icon: 'assets/imgs/pins/redpin.png',
enableHighAccuracy:true
})
//For position update(this is a code which is not working)
let watch = this.geolocation.watchPosition();
watch.subscribe((data) => {
// data can be a set of coordinates, or an error (if an error occurred).
// data.coords.latitude
// data.coords.longitude
});