網站搜尋

angular - Nativescript。Mapbox。Typescript + Angular2


我在我的應用程式中使用 Mapbox。當我在頁面上導航時,也就是我使用地圖的頁面,一切都運作正常。之後,我點擊其中一個標記,並導航到下一個頁面。但當我在下一個頁面點擊返回按鈕,或者調用 routerExtensions.back() 時,我會返回帶有地圖的頁面,但地圖消失了。我仍然可以在地圖標記上盲點,並導航到下一個頁面,但我看不到地圖。

這裡是含有映射的類的代碼:

export class CarwashListComponent implements OnInit {

    ngOnInit() {
        this.initMap();
    }

    initMap() {
        var _this = this;
        this.mapbox.show({
            accessToken: "pk.eyJ1IjoiaWxqYWdyYWJhcjE0IiwiYSI6ImNpd25laGw2YTAwMTIyeW10ZXM0a3l6M2UifQ.CfGJKVjVzM-lRzko7cP37g",
            mapStyle: "light",
            center: { // optional without a default
                lat: this.cities[0]['coordinates'][1],
                lng: this.cities[0]['coordinates'][0]
              },
            markers: [
                {
                 lat: 52.3732160, 
                 lng: 4.8941680, 
                 title: 'Nice location', 
                 subtitle: 'Really really nice location', 
                 onCalloutTap: function () {
                                 _this.routerExtensions.navigate(["next_page"]))
               }
            ],
            zoomLevel:9.5,
            showUserLocation: "true"
      })
   }
}

我做錯了什麼?