UNPKG

@nativescript-community/ui-carto

Version:

NativeScript plugin for CARTO Mobile SDK

126 lines 5.17 kB
import { Color } from '@nativescript/core'; import { mapPosVectorFromArgs, nativeColorProperty, nativeMapVecProperty, nativeProperty } from '../'; import { DoubleVector, fromNativeMapPos, toNativeMapPos } from '../core'; import { RasterTileLayerBase } from './raster.common'; export const RasterTileFilterMode = { get RASTER_TILE_FILTER_MODE_NEAREST() { return com.carto.layers.RasterTileFilterMode.RASTER_TILE_FILTER_MODE_NEAREST; }, get RASTER_TILE_FILTER_MODE_BILINEAR() { return com.carto.layers.RasterTileFilterMode.RASTER_TILE_FILTER_MODE_BILINEAR; }, get RASTER_TILE_FILTER_MODE_BICUBIC() { return com.carto.layers.RasterTileFilterMode.RASTER_TILE_FILTER_MODE_BICUBIC; } }; export class RasterTileLayerCommon extends RasterTileLayerBase { constructor(options) { super(options); for (const property of ['elementListener', 'nElementListener']) { const descriptor = Object.getOwnPropertyDescriptor(RasterTileLayer.prototype, property); if (descriptor) { descriptor.enumerable = false; } } } setRasterTileEventListener(listener, projection) { this.clickListener = listener; this.projection = projection; if (listener) { if (!this.nClickListener) { this.nClickListener = new com.akylas.carto.additions.AKRasterTileEventListener(new com.akylas.carto.additions.AKRasterTileEventListener.Listener({ onRasterTileClicked: this.onRasterTileClicked.bind(this) })); } this.getNative().setRasterTileEventListener(this.nClickListener); } else { this.nClickListener = null; this.getNative().setRasterTileEventListener(null); } } onRasterTileClicked(info) { if (this.clickListener && this.clickListener.onRasterTileClicked) { let position = info.getClickPos(); if (this.projection) { const layerProj = this.getNative().getDataSource().getProjection(); const nProj = this.projection.getNative(); position = nProj.fromWgs84(layerProj.toWgs84(position)); } return (this.clickListener.onRasterTileClicked.call(this.clickListener, { clickType: info.getClickType().swigValue(), layer: this, nearestColor: new Color(info.getNearestColor().getARGB()), interpolatedColor: new Color(info.getInterpolatedColor().getARGB()), position: fromNativeMapPos(position) }) || false); } return false; } } export class RasterTileLayer extends RasterTileLayerCommon { createNative(options) { return new com.carto.layers.RasterTileLayer(options.dataSource.getNative()); } } __decorate([ nativeProperty ], RasterTileLayer.prototype, "tileFilterMode", void 0); export class HillshadeRasterTileLayer extends RasterTileLayerCommon { createNative(options) { if (options.decoder) { return new com.akylas.carto.additions.AKHillshadeRasterTileLayer(options.dataSource.getNative(), options.decoder.getNative()); } else { return new com.akylas.carto.additions.AKHillshadeRasterTileLayer(options.dataSource.getNative()); } } getElevation(pos) { return this.getNative().getElevation(toNativeMapPos(pos)); } getElevations(pos) { return new DoubleVector(this.getNative().getElevations(mapPosVectorFromArgs(pos))); } getElevationAsync(pos, callback) { this.getNative().getElevationCallback(toNativeMapPos(pos), new com.akylas.carto.additions.AKHillshadeRasterTileLayer.ElevationCallback({ onElevation(err, res) { callback(err, res); } })); } getElevationsAsync(pos, callback) { this.getNative().getElevationsCallback(mapPosVectorFromArgs(pos), new com.akylas.carto.additions.AKHillshadeRasterTileLayer.ElevationsCallback({ onElevations(err, res) { callback(err, new DoubleVector(res)); } })); } } __decorate([ nativeProperty ], HillshadeRasterTileLayer.prototype, "heightScale", void 0); __decorate([ nativeProperty ], HillshadeRasterTileLayer.prototype, "contrast", void 0); __decorate([ nativeProperty ], HillshadeRasterTileLayer.prototype, "exagerateHeightScaleEnabled", void 0); __decorate([ nativeProperty ], HillshadeRasterTileLayer.prototype, "normalMapLightingShader", void 0); __decorate([ nativeMapVecProperty ], HillshadeRasterTileLayer.prototype, "illuminationDirection", void 0); __decorate([ nativeColorProperty ], HillshadeRasterTileLayer.prototype, "highlightColor", void 0); __decorate([ nativeColorProperty ], HillshadeRasterTileLayer.prototype, "shadowColor", void 0); __decorate([ nativeColorProperty ], HillshadeRasterTileLayer.prototype, "accentColor", void 0); __decorate([ nativeProperty ], HillshadeRasterTileLayer.prototype, "tileFilterMode", void 0); //# sourceMappingURL=raster.android.js.map