[英]Nativescript + Angular2 Apple Maps
I am trying to create an Apple Map(MapKit) based app using Nativescript+NG2 and I am not sure how to go about including the map on the template. 我正在尝试使用Nativescript + NG2创建一个基于Apple Map(MapKit)的应用程序,我不确定如何在模板上包括地图。 I have tried this plugin in Nativescript-JS app where it works but not in NS+NG2. 我已经在Nativescript-JS应用程序中尝试过该插件 ,但在NS + NG2中却无法使用。
I tried to create MapViewEl as below and doesn't display any errors or the map. 我尝试如下创建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>"
})
Any links or directions on how to approach this. 有关如何解决此问题的任何链接或说明。
Thanks 谢谢
Alright, after so many trail and errors I found it, 好吧,经过如此多的探索和发现,我发现了它,
I missed the registerElement part of it, 我错过了其中的registerElement部分,
//in app.component.ts
registerElement("MapViewEl", () => require("./mapsnew").MapViewEl);
@Component({
selector:"<my-app></my-app>"
template:"<StackLayout><MapViewEl></MapViewEl></StackLayout>"
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.