【问题标题】:Nativescript + Angular2 Apple MapsNativescript + Angular2 苹果地图
【发布时间】:2016-09-23 14:40:20
【问题描述】:

我正在尝试使用 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>"
})

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

谢谢

【问题讨论】:

    标签: angular nativescript angular2-nativescript


    【解决方案1】:

    好吧,经过这么多线索和错误我找到了它,

    我错过了它的 registerElement 部分,

    //in app.component.ts
    registerElement("MapViewEl", () => require("./mapsnew").MapViewEl);
    
    @Component({
       selector:"<my-app></my-app>"
       template:"<StackLayout><MapViewEl></MapViewEl></StackLayout>"
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-21
      相关资源
      最近更新 更多