/** * Android Implementation * * @todo FIXME: The gcFix() implementation currently assumes only one map visible at a time. */ import { ImageSource } from '@nativescript/core'; import { AddExtrusionOptions, AddGeoJsonClusteredOptions, AddPolygonOptions, AddPolylineOptions, AddSourceOptions, AnimateCameraOptions, DeleteOfflineRegionOptions, DownloadOfflineRegionOptions, Feature, LatLng, LayerCommon, ListOfflineRegionsOptions, MapStyle, MapboxApi, MapboxCommon, MapboxMarker, MapboxViewBase, OfflineRegion, QueryRenderedFeaturesOptions, QuerySourceFeaturesOptions, SetCenterOptions, SetTiltOptions, SetViewportOptions, SetZoomLevelOptions, ShowOptions, ShowResult, TrackUserOptions, UpdateSourceOptions, UserLocation, UserLocationCameraMode, Viewport, telemetryProperty } from './common'; import { AndroidMarker } from './markers/Marker.android'; export * from './common'; export declare function setLogLevel(level: 'none' | 'info' | 'debug' | 'error' | 'fault' | 'verbose'): void; /** * A map view created in XML. * * This is the class that is created when the Mapbox XML tag * is encountered while parsing a view. * * Angular components need to register the Mapbox tag as follows: * * import { registerElement } from "nativescript-angular/element-registry"; * registerElement( "Mapbox", () => require("nativescript-mapbox").MapboxView); * * The registerElement call is what binds the XML tag to the class that creates it. * * @see MapboxViewBase */ export declare class MapboxView extends MapboxViewBase { [telemetryProperty.setNative]: (value: boolean) => void; private nativeMapView; mapbox: Mapbox; private settings; private initialized; constructor(); /** * programmatically include settings */ setConfig(settings: ShowOptions): void; getNativeMapView(): any; /** * Return the Mapbox() API Shim instance * * This returns a reference to the Mapbox API shim class instance. * See class Mapbox below. * * @see Mapbox */ getMapboxApi(): Mapbox; /** * Creates the native view. * * This method is supposed to create the native view. NativeScript caches * and re-uses views to save on memory and increase performance. Unfortunately, * the inner details of exactly how this is done is challenging to tease apart. * * The problem is that in order to create the Mapbox view we need the access token from * the XML, but in the case of a pure NativeScript app with property binding * (see the demo), the properties don't seem to be available until the page is loaded. * * As a workaround, I wait until the page is loaded to configure the map. See initNativeView. * * It seems to me there should be a better way. * * @link https://docs.nativescript.org/core-concepts/properties#views-lifecycle-and-recycling * * @todo check this. */ createNativeView(): object; onLoaded(): void; onUnloaded(): void; initNativeView(): void; /** * when the view is destroyed. * * This is called by the framework when the view is actually destroyed. * NativeScript, by design, tries to cache native views because * creating native views is expensive. * * @link https://docs.nativescript.org/plugins/ui-plugin-custom */ disposeNativeView(): void; /** * initialize the map * * This method creates a new mapbox API instance and, through the show() method of the Mapbox API, * creates a Mapbox native map view. * * @see show() * * @link https://docs.nativescript.org/core-concepts/events * * @todo FIXME: this.nativeMapView is unused and never actually set to anything. */ initMap(): Promise; } /** * A NativeScript shim for the Mapbox API. * * This implements a Typescript shim over the Native Mapbox GL Android API. * * It is created in one of two ways: * * - directly via let mapbox = new Mapbox(); mapbox.show( ... ) * - via the Mapbox XML tag in which case a MapboxView object is created which hosts a reference to this class. (See MapboxView::getMapboxAPI()) */ export declare class Mapbox extends MapboxCommon implements MapboxApi { private _mapboxMapInstance; private _mapboxViewInstance; private _accessToken; private lineManager; private polygonManager; private _offlineManager; private _tileStore; private markerManager; private customMarker; private onAnnotationClickListener; private onMapClickListener; private onMapLongClickListener; private onMoveEndListener; private onMoveBeginListener; private onScrollListener; private onFlingListener; private onCameraMoveListener; private onCameraMoveCancelListener; private onMapIdleListener; onIndicatorPositionChangedListener: com.mapbox.maps.plugin.locationcomponent.OnIndicatorPositionChangedListener; lastKnownLocation: com.mapbox.geojson.Point; private _markers; private _polylines; private _polygons; private lines; private eventCallbacks; _markerIconDownloadCache: { [k: string]: ImageSource; }; constructor(view: any); getMapInstance(): com.mapbox.maps.MapboxMap; /** * not used */ setMapboxViewInstance(mapboxViewInstance: any): void; /** * show the map programmatically. * * This method is used to programmatically display a map. It is also called * by the MapboxView::init() method which initializes the map when the Mapbox * XML tags is encountered * * options may additionally include: * * - context * - parentView * - onLocationPermissionGranted * - onLocationPermissionDenied * - onMapReady * * @see MapboxView::init() * */ show(options: ShowOptions): Promise; /** * hide the map */ hide(): Promise; unhide(): Promise; destroy(nativeMap?: com.mapbox.maps.MapboxMap): Promise; /** * Clear Event Listeners * * Explicitly clear all registered event listeners. It's not clear to me whether or not this * is strictly necessary as I imagine these should all get cleaned up when the map is destroyed * but given the complication of NativeScript's garbage collection scheme it seems like a good * idea to remove these handlers explicitly. */ private clearEventListeners; onStart(nativeMap?: com.mapbox.maps.MapboxMap): Promise; onStop(nativeMap?: com.mapbox.maps.MapboxMap): Promise; onDestroy(nativeMap?: com.mapbox.maps.MapboxMap): Promise; /** * event handler shim * * Initialize our event handler shim so that we can intercept events here. * * @param { any } settings * @param { MapboxView } mapboxView */ initEventHandlerShim(settings: any, mapboxNativeViewInstance: any): void; /** * register on click handlers. * * The native mapbox API does not, apparently, support click handlers * on circles, but it does for markers and polylines. WTF? * * Here we attempt to replicate the mapbox-gl-js behaviour of being * able to assign an onClick handler to a layer by it's layer id. * * @param {string} event - the event to subscribe to. i.e. 'click'. * @param {string} id - the id of the layer * @param {function} callback - the callback to invoke when the layer is clicked on. * @param {object] nativeMapView - reference to the native Map view. * * @link https://github.com/mapbox/mapbox-android-demo/issues/540 */ onMapEvent(eventName: any, id: any, callback: any, nativeMapView?: any): void; /** * remove an event handler for a layer * * This will remove all event handlers (that we manage here) for * the given layer id and event. */ offMapEvent(eventName: any, id: any, nativeMapView?: any): void; /** * If click events registered and a feature found for the event, then fire listener. */ private checkForClickEvent; /** * handles a line click event * * Given a click on a line overlay, find the id of the underlying line layer * an invoke any registered callbacks. */ private handleLineClickEvent; /** * set the map style * * The 7.X version of the SDK uses a builder class for forming * URLs. * * NOTE: The style must be explicitly set using this method in the onMapReady() handler. * * @param {string | MapStyle } style - a style following the Mapbox style specification or a URL to a style. * @param {any} nativeMapViewInstance - native map view (com.mapbox.maps.MapView) * * @see MapboxViewCommonBase:setMapStyle() * * @link https://docs.mapbox.com/android/api/map-sdk/7.1.2/com/mapbox/mapboxsdk/maps/Style.Builder.html * @link https://docs.mapbox.com/android/api/map-sdk/7.1.2/com/mapbox/mapboxsdk/maps/MapboxMap.html#setStyle-java.lang.String-com.mapbox.maps.Style.OnStyleLoaded- */ setMapStyle(style: string | MapStyle, nativeMapViewInstance?: any): Promise; getImage(imageId: string, nativeMap?: com.mapbox.maps.MapboxMap): Promise; addImage(imageId: string, imagePath: string, nativeMap?: com.mapbox.maps.MapboxMap): Promise; removeImage(imageId: string, nativeMap?: com.mapbox.maps.MapboxMap): Promise; /** * * @deprecated * @link https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation */ addMarkers(markers: MapboxMarker[], nativeMap?: com.mapbox.maps.MapboxMap): Promise; /** * * @deprecated * @link https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation */ removeMarkers(ids?: any, nativeMap?: com.mapbox.maps.MapboxMap): Promise; iconCache: { [k: string]: ImageSource; }; _addMarkers(markers: MapboxMarker[], nativeMap?: any): Promise; /** * * @deprecated */ _removeMarkers(ids?: any, nativeMap?: any): void; setCenter(options: SetCenterOptions, nativeMap?: any): Promise; getCenter(nativeMap?: any): Promise; setZoomLevel(options: SetZoomLevelOptions, nativeMap?: any): Promise; getZoomLevel(nativeMap?: any): Promise; setTilt(options: SetTiltOptions, nativeMap?: any): Promise; getTilt(nativeMap?: any): Promise; /** * get users current location * * @link https://docs.mapbox.com/android/api/map-sdk/9.0.0/com/mapbox/mapboxsdk/location/LocationComponent.html#getLastKnownLocation-- */ getUserLocation(): Promise; /** * @link https://www.mapbox.com/android-docs/api/mapbox-java/libjava-geojson/3.4.1/com/mapbox/geojson/Feature.html */ queryRenderedFeatures(options: QueryRenderedFeaturesOptions): Promise; querySourceFeatures(sourceId: string, options?: QuerySourceFeaturesOptions): Promise; /** * * @deprecated */ addPolygon(options: AddPolygonOptions, nativeMap?: any): Promise; /** * * @deprecated */ addPolyline(options: AddPolylineOptions, nativeMap?: any): Promise; removePolygons(ids?: any[], nativeMap?: any): Promise; removePolylines(ids?: any[], nativeMap?: any): Promise; animateCamera(options: AnimateCameraOptions, nativeMap?: any): Promise; setOnMapClickListener(listener: (data: LatLng) => boolean, nativeMap?: com.mapbox.maps.MapboxMap): Promise; setOnMapLongClickListener(listener: (data: LatLng) => boolean, nativeMap?: any): Promise; setOnMoveBeginListener(listener: (data?: LatLng) => void, nativeMap?: any): Promise; setOnMoveEndListener(listener: (data?: LatLng) => void, nativeMap?: any): Promise; setOnScrollListener(listener: (data?: LatLng) => void, nativeMap?: any): Promise; setOnFlingListener(listener: () => void, nativeMap?: any): Promise; setOnCameraChangeListener(listener: (reason: any, animated?: any) => void, nativeMap?: any): Promise; setOnCameraMoveCancelListener(listener: () => void, nativeMap?: any): Promise; setOnMapIdleListener(listener: () => void, nativeMap?: any): Promise; getViewport(nativeMap?: any): Promise; setViewport(options: SetViewportOptions, nativeMap?: any): Promise; downloadOfflineRegion(options: DownloadOfflineRegionOptions): Promise; listOfflineRegions(options?: ListOfflineRegionsOptions): Promise; deleteOfflineRegion(options: DeleteOfflineRegionOptions): Promise; _getOfflineManager(): com.mapbox.maps.OfflineManager; _getTileStore(): com.mapbox.common.TileStore; addExtrusion(options: AddExtrusionOptions, nativeMap?: any): Promise; /** * update a geojson source * */ updateSource(id: string, options: UpdateSourceOptions, nativeMap?: any): Promise; /** * add a geojson or vector source * * Add a source that can then be referenced in the style specification * passed to addLayer(). * * @link https://docs.mapbox.com/mapbox-gl-js/api/#map#addsource */ addSource(id: string, options: AddSourceOptions, nativeMap?: com.mapbox.maps.MapboxMap): Promise; /** * remove source by id */ removeSource(id: string, nativeMap?: com.mapbox.maps.MapboxMap): Promise; /** * a rough analogue to the mapbox-gl-js addLayer() method * * It would be nice if this {N} API matched the mapbox-gl-js API which * would make it much easier to share mapping applications between the web * and {N} apps. * * This method accepts a Mapbox-GL-JS style specification JSON object with some * limitations: * * - the source: must be a GeoJSON object, vector source definition, or an id of a source added via addSource() * - only a subset of paint properties are available. * * @param {object} style - a style following the Mapbox style specification. * @param {any} nativeMapView - native map view (com.mapbox.maps.MapView) * * @link https://docs.mapbox.com/mapbox-gl-js/style-spec/#layers */ addLayer(style: any, belowLayerId?: string, nativeMap?: com.mapbox.maps.MapboxMap): Promise; /** * remove layer by ID * * Removes a layer given a layer id * * @param {string} id */ removeLayer(id: string, nativeMap?: com.mapbox.maps.MapboxMap): Promise; private getSource; /** * @deprecated * Add a point to a line * * This method appends a point to a line and is useful for drawing a users track. * * @param {id} id - id of line to add a point to. * @param {array} lnglat - [lng,lat] to append to the line. * * @link https://github.com/mapbox/mapbox-gl-native/issues/13983 * @link https://docs.mapbox.com/android/api/mapbox-java/libjava-geojson/3.0.1/com/mapbox/geojson/Feature.html#Feature-- * @link https://docs.oracle.com/javase/8/docs/api/java/util/List.html */ addLinePoint(id: string, lnglat: any, sourceId?: string, nativeMapView?: any): Promise; addGeoJsonClustered(options: AddGeoJsonClusteredOptions, nativeMap?: any): Promise; /** * constantly center the map on the users location. */ trackUser(options: TrackUserOptions, nativeMap?: any): Promise; private static getAndroidColor; _getMapStyle(input?: string): any; /** * Mapbox Map Options * * @link https://github.com/mapbox/mapbox-gl-native/wiki/Android-6.x-to-7.x-migration-guide * @link https://github.com/mapbox/mapbox-gl-native/blob/master/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java * @link https://docs.mapbox.com/android/api/map-sdk/7.1.2/com/mapbox/mapboxsdk/maps/MapboxMapOptions.html */ _getMapboxMapOptions(context: android.content.Context, settings: ShowOptions): com.mapbox.maps.MapInitOptions; private static mapPositionToGravity; /** * convert string to camera mode constant. * * @link https://docs.mapbox.com/android/api/map-sdk/8.1.0/com/mapbox/mapboxsdk/location/modes/CameraMode.html */ _fineLocationPermissionGranted(): boolean; _getRegionName(offlineRegion: com.mapbox.common.TileRegion): Promise; _getRegionMetadata(offlineRegion: com.mapbox.common.TileRegion): Promise>; _plugins: { [k: string]: com.mapbox.maps.plugin.MapPlugin; }; _getPlugin(pluginId: string): T; _getGesturesPlugin(): com.mapbox.maps.plugin.gestures.GesturesPlugin; /** * show a user location marker * * This method must not be called before location permissions have been granted. * * Supported options are: * * - foregroundTintColor * - foregroundStaleTintColor * - backgroundTintColor * - bearingTintColor * - elevation * - accuracyColor * - accuracyAlpha * - useDefaultLocationEngine * - renderMode * - cameraMode * - clickListener * - cameraTrackingChangeListener * * @param {object} options * * @link https://github.com/mapbox/mapbox-android-demo/blob/master/MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/location/LocationComponentOptionsActivity.java * @link https://developer.android.com/reference/android/graphics/Color * * @todo at least with simulated data, the location is only updated once hence adding support for forceLocation method. */ showUserLocationMarker(options: Partial, nativeMap?: any): Promise; /** * hide (destroy) the user location marker * * This method destroys the user location marker. */ hideUserLocationMarker(nativeMap?: any): Promise; /** * Change the mode of the user location marker * * Used to change the camera tracking and render modes of an existing * marker. * * The marker must be configured using showUserLocationMarker before this method * can called. */ changeUserLocationMarkerMode(renderMode: any, cameraMode: UserLocationCameraMode, nativeMap?: any): Promise; /** * force updating of user location * * This method forces the user location marker, if displayed, to move to a new location * * @todo figure out why the user location marker is not updating. */ forceUserLocationUpdate(location: any, nativeMap?: any): Promise; getLayer(name: string, nativeMap?: com.mapbox.maps.MapboxMap): Promise; getLayers(nativeMap?: com.mapbox.maps.MapboxMap): Promise; _getClickedMarkerDetails(clicked: AndroidMarker): MapboxMarker; _downloadImage(marker: MapboxMarker): Promise; _downloadMarkerImages(markers: MapboxMarker[]): Promise; project(data: LatLng): { x: number; y: number; }; projectBack(screenCoordinate: { x: number; y: number; }): LatLng; }