Nativescript + Angular2 Apple Maps

时间:2016-09-22 02:20:59

标签: angular nativescript angular2-nativescript

我正在尝试使用Nativescript + NG2创建一个基于Apple Map(MapKit)的应用程序,我不知道如何在模板上包含地图。我在Nativescript-JS应用程序中尝试了这个plugin,但在NS + NG2中没有。

我尝试按如下所示创建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>"
})

有关如何处理此问题的任何链接或说明。

由于

1 个答案:

答案 0 :(得分:0)

好吧,经过这么多的追踪和错误,我找到了它,

我错过了它的registerElement部分,

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

@Component({
   selector:"<my-app></my-app>"
   template:"<StackLayout><MapViewEl></MapViewEl></StackLayout>"
})
相关问题