UNPKG

@nativescript-community/ui-mapbox

Version:

Interactive, thoroughly customizable maps powered by vector tiles and OpenGL.

51 lines 2.22 kB
import { Trace } from '@nativescript/core'; import { CLog, CLogTypes } from '../common'; /** * Hybrid Marker — uses native Mapbox annotation APIs, but NativeScript view for info window. */ export class AndroidMarker { constructor(opts) { this.position = opts.position; this.id = opts.id; this.icon = opts.icon; this.title = opts.title; this.snippet = opts.snippet; } /** * Create the native PointAnnotation */ prepareAnnotationMarker(pointAnnotationManager, layerId) { const IconAnchor = com.mapbox.maps.extension.style.layers.properties.generated.IconAnchor; const PointAnnotationOptions = com.mapbox.maps.plugin.annotation.generated.PointAnnotationOptions; this.pointAnnotation = pointAnnotationManager.create(new PointAnnotationOptions().withPoint(this.position).withIconAnchor(IconAnchor.valueOf('BOTTOM')).withIconImage(this.icon)); this.layerId = layerId; if (Trace.isEnabled()) { CLog(CLogTypes.log, 'MarkerManager prepareAnnotationMarker: ' + layerId, this.id, this.pointAnnotation); } } update(pointAnnotationManager) { if (!this.pointAnnotation) { return; } // const PointAnnotationOptions = com.mapbox.maps.plugin.annotation.generated.PointAnnotationOptions; // const IconAnchor = com.mapbox.maps.extension.style.layers.properties.generated.IconAnchor; this.pointAnnotation.setGeometry(this.position); // this.pointAnnotation.setIconAnchor(IconAnchor.BOTTOM); this.pointAnnotation.setIconImageBitmap(this.icon); // 2. Update the annotation via the manager pointAnnotationManager.update(this.pointAnnotation); if (this.view) { const title = this.view.getViewById('title'); title.text = this?.title || ''; const subtitle = this.view.getViewById('subtitle'); subtitle.text = this?.snippet; subtitle.visibility = this?.snippet ? 'visible' : 'collapse'; } } destroy() { this.view = null; this.viewAnnotation = null; this.icon = null; } } //# sourceMappingURL=Marker.android.js.map