@nativescript-community/ui-carto
Version:
NativeScript plugin for CARTO Mobile SDK
128 lines • 5.31 kB
JavaScript
import { RasterTileLayerBase } from './raster.common';
import { mapPosVectorFromArgs, nativeMapVecProperty, nativeProperty } from '../';
import { DoubleVector, fromNativeMapPos, toNativeMapPos } from '../core';
import { Color } from '@nativescript/core';
import { nativeColorProperty } from '../index.ios';
export const RasterTileFilterMode = {
get RASTER_TILE_FILTER_MODE_NEAREST() {
return 0 /* NTRasterTileFilterMode.T_RASTER_TILE_FILTER_MODE_NEAREST */;
},
get RASTER_TILE_FILTER_MODE_BILINEAR() {
return 1 /* NTRasterTileFilterMode.T_RASTER_TILE_FILTER_MODE_BILINEAR */;
},
get RASTER_TILE_FILTER_MODE_BICUBIC() {
return 2 /* NTRasterTileFilterMode.T_RASTER_TILE_FILTER_MODE_BICUBIC */;
}
};
var NTRasterTileEventListenerImpl = /** @class */ (function (_super) {
__extends(NTRasterTileEventListenerImpl, _super);
function NTRasterTileEventListenerImpl() {
return _super !== null && _super.apply(this, arguments) || this;
}
NTRasterTileEventListenerImpl.initWithOwner = function (owner, layer, projection) {
var delegate = NTRasterTileEventListenerImpl.new();
delegate._owner = owner;
delegate._layer = layer;
delegate.projection = projection;
return delegate;
};
NTRasterTileEventListenerImpl.prototype.onRasterTileClickedThreaded = function (info) {
var owner = this._owner.get();
if (owner && owner.onRasterTileClicked) {
var position = info.getClickPos();
if (this.projection) {
var layerProj = this._layer.get().getNative().getDataSource().getProjection();
var nProj = this.projection.getNative();
position = nProj.fromWgs84(layerProj.toWgs84(position));
}
return (owner.onRasterTileClicked({
clickType: info.getClickType(),
layer: this._layer.get(),
nearestColor: new Color(info.getNearestColor().getARGB()),
interpolatedColor: new Color(info.getInterpolatedColor().getARGB()),
position: fromNativeMapPos(position)
}) || false);
}
return false;
};
return NTRasterTileEventListenerImpl;
}(AKRasterTileEventListener));
export { NTRasterTileEventListenerImpl };
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) {
this.nClickListener = NTRasterTileEventListenerImpl.initWithOwner(new WeakRef(listener), new WeakRef(this), projection);
this.getNative().setRasterTileEventListener(this.nClickListener);
}
else {
this.nClickListener = null;
this.getNative().setRasterTileEventListener(null);
}
}
}
export class RasterTileLayer extends RasterTileLayerCommon {
createNative(options) {
return NTRasterTileLayer.alloc().initWithDataSource(options.dataSource.getNative());
}
}
export class HillshadeRasterTileLayer extends RasterTileLayerBase {
createNative(options) {
if (options.decoder) {
return AKHillshadeRasterTileLayer.alloc().initWithDataSourceElevationDecoder(options.dataSource.getNative(), options.decoder.getNative());
}
else {
return AKHillshadeRasterTileLayer.alloc().initWithDataSource(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), (res) => callback(null, res));
}
getElevationsAsync(pos, callback) {
this.getNative().getElevationsCallback(mapPosVectorFromArgs(pos), (res) => callback(null, 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.ios.js.map