2016-09-22 77 views
0

我正在嘗試使用Nativescript + NG2創建基於Apple Map(MapKit)的應用程序,我不知道如何在模板中包含地圖。我已經在Nativescript-JS應用程序中嘗試過plugin,但它在NS + NG2中不起作用。Nativescript + Angular2 Apple Maps

我試着像下面那樣創建MapViewEl,並且不顯示任何錯誤或地圖。

declare var MKMapView: any; 
declare var UIScreen: any; 

export class MapViewEl { 
    private _ios: any; 
    constructor() { 
     console.log("MapViewEl"); 
     this._ios = MKMapView.alloc().initWithFrame(UIScreen.mainScreen().bounds);  
    } 

    get ios(): any { 
     return this._ios; 
    } 
} 


//in app.component.ts 
@Component({ 
    selector:"<my-app></my-app>" 
    template:"<StackLayout><MapViewEl></MapViewEl></StackLayout>" 
}) 

對如何處理這個任何鏈接或方向。

感謝

回答

0

好了,那麼多的記錄和錯誤之後,我發現它,

我錯過了它的registerElement部分,

//in app.component.ts 
registerElement("MapViewEl",() => require("./mapsnew").MapViewEl); 

@Component({ 
    selector:"<my-app></my-app>" 
    template:"<StackLayout><MapViewEl></MapViewEl></StackLayout>" 
}) 
相關問題