我是Ionic的新手,只是修复了我的应用中的地理位置。我现在可以在地图上看到我的位置,但我在地图上没有更新位置的问题。我尝试了所有可能的方法并google了很多,也在Stackoverflow上阅读,但仍然没有任何工作。职位没有更新。请你看看我的代码并告诉我我做错了什么?
@ViewChild('autoC') auto: HTMLElement;
答案 0 :(得分:0)
您可以尝试使用watchPosition
方法代替getCurrentPosition
类似的方法:
loadMap() {
this.geolocation.watchPosition().subscribe((position) => {
let latLng = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
let marker = new google.maps.Marker({
map: this.map,
icon: 'assets/imgs/pins/redpin.png',
position: latLng,
enableHighAccuracy:true
});
let message = "Current Position";
this.addInfoWindow(marker, content);
}, (err) => {console.log(err);} );
}