@nativescript-community/ui-carto
Version:
NativeScript plugin for CARTO Mobile SDK
97 lines • 3.25 kB
JavaScript
import { nativeProperty } from '..';
import { TileDataSource } from '../datasources';
import { Projection } from '../projections';
import { BaseLayer } from './index.common';
export const TileSubstitutionPolicy = {
get TILE_SUBSTITUTION_POLICY_ALL() {
return com.carto.layers.TileSubstitutionPolicy.TILE_SUBSTITUTION_POLICY_ALL;
},
get TILE_SUBSTITUTION_POLICY_VISIBLE() {
return com.carto.layers.TileSubstitutionPolicy.TILE_SUBSTITUTION_POLICY_VISIBLE;
},
get TILE_SUBSTITUTION_POLICY_NONE() {
return com.carto.layers.TileSubstitutionPolicy.TILE_SUBSTITUTION_POLICY_NONE;
}
};
export class Layer extends BaseLayer {
get visibleZoomRange() {
if (this.native) {
const zoomRange = this.native.getVisibleZoomRange();
return [zoomRange.getMin(), zoomRange.getMax()];
}
return this.options.visibleZoomRange;
}
set visibleZoomRange(value) {
this.native && this.native.setVisibleZoomRange(new com.carto.core.MapRange(value[0], value[1]));
}
get minVisibleZoom() {
if (this.native) {
const zoomRange = this.native.getVisibleZoomRange();
return zoomRange.getMin();
}
return this.options.visibleZoomRange?.[0];
}
set minVisibleZoom(value) {
if (this.native) {
const zoomRange = this.native.getVisibleZoomRange();
this.native.setVisibleZoomRange(new com.carto.core.MapRange(value, zoomRange.getMax()));
}
}
get maxVisibleZoom() {
if (this.native) {
const zoomRange = this.native.getVisibleZoomRange();
return zoomRange.getMax();
}
return this.options.visibleZoomRange?.[1];
}
set maxVisibleZoom(value) {
if (this.native) {
const zoomRange = this.native.getVisibleZoomRange();
this.native.setVisibleZoomRange(new com.carto.core.MapRange(zoomRange.getMin(), value));
}
}
refresh() {
this.native && this.native.refresh();
}
}
export class TileLayer extends Layer {
clearTileCaches(all) {
if (this.native) {
this.native.clearTileCaches(all);
}
}
get dataSource() {
if (this.options.dataSource) {
return this.options.dataSource;
}
return new TileDataSource(undefined, this.getNative().getDataSource());
}
set dataSource(value) {
// no op cant change!
}
get projection() {
if (this.options['projection']) {
return this.options['projection'];
}
return new Projection(undefined, this.getNative().getDataSource().getProjection());
}
}
__decorate([
nativeProperty
], TileLayer.prototype, "preloading", void 0);
__decorate([
nativeProperty
], TileLayer.prototype, "synchronizedRefresh", void 0);
__decorate([
nativeProperty
], TileLayer.prototype, "zoomLevelBias", void 0);
__decorate([
nativeProperty
], TileLayer.prototype, "maxOverzoomLevel", void 0);
__decorate([
nativeProperty
], TileLayer.prototype, "maxUnderzoomLevel", void 0);
__decorate([
nativeProperty
], TileLayer.prototype, "tileSubstitutionPolicy", void 0);
//# sourceMappingURL=index.android.js.map