To use the mobile Mapbox component in custom code, you need access to the MapboxViewApi object. The onMapReady event receives this object and makes it available through the ksMapbox.mapView property.


The following example injects a reference to ksMapbox using the @ViewChild decorator with the id selector. Angular makes the value of the injected reference available on the ngAfterViewInit event. The ngAfterViewInit method override at the end adds a wrapper function for the mapReady event.


@ViewChild('mapboxRef', { static: false })
public ksMapbox: KSMapboxComponent;
//...
public ngAfterViewInit() {
    super.ngAfterViewInit();

    const originalMapReady = this.ksMapbox.onMapReady;
    this.ksMapbox.onMapReady = (...args) => {
        originalMapReady.call(this.ksMapbox, ...args);
        // custom logic here
        this.ksMapbox.mapView.getUserLocation();
    };
}