简体   繁体   中英

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. I have tried this plugin in Nativescript-JS app where it works but not in NS+NG2.

I tried to create MapViewEl as below and doesn't display any errors or the map.

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,

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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