0

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

1 Answer 1

1

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>"
})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.