2016-09-22 64 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>" 
}) 
相关问题