繁体   English   中英

Nativescript + Angular2苹果地图

[英]Nativescript + Angular2 Apple Maps

我正在尝试使用Nativescript + NG2创建一个基于Apple Map(MapKit)的应用程序,我不确定如何在模板上包括地图。 我已经在Nativescript-JS应用程序中尝试过该插件 ,但在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>"
})

有关如何解决此问题的任何链接或说明。

谢谢

好吧,经过如此多的探索和发现,我发现了它,

我错过了其中的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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM