【发布时间】:2017-08-13 10:45:42
【问题描述】:
我有一个包含 2 页的 Ionic 2 应用程序。当我点击主页上的一个按钮时,它会将我带到一个页面,其中我们有一张地图,可以定位当前位置和附近的位置。显示所有位置,但是当我返回主页并重新单击按钮时,第二页中的地图仅显示当前位置而不是附近。 这是初始化第二页的代码:
ionViewDidLoad(){
this.platform.ready().then(() => {
let mapLoaded = this.maps.init(this.mapElement.nativeElement, this.pleaseConnect.nativeElement);
let locationsLoaded = this.locations.load();
Promise.all([
mapLoaded,
locationsLoaded
]).then((result) => {
let locations = result[1];
for(let location of locations){
this.maps.addMarker(location.latitude, location.longitude,'http://maps.google.com/mapfiles/ms/icons/blue-dot.png');
}
});
});
【问题讨论】:
-
你在ionViewWillEnter中试过你的功能了吗?
标签: angular typescript ionic2 promise