【发布时间】:2018-05-09 16:18:11
【问题描述】:
我是 Ionic 的新手,只是在我的应用程序中修复了地理位置。我现在可以在地图上看到我的位置,但我遇到了位置没有在地图上更新的问题。我尝试了所有可能的方法并在 Google 上搜索了很多内容,并在 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
});
【问题讨论】:
标签: ionic-framework geolocation