UNPKG

@nativescript-community/ui-carto

Version:

NativeScript plugin for CARTO Mobile SDK

170 lines 5.44 kB
// import { BaseVectorElement } from './vectorelements.common'; import { nativeProperty } from '../index.common'; import { BaseNative } from '../BaseNative'; import { nativeMapToJS } from '../utils'; import { fromNativeMapPos, toNativeMapPos } from '../core'; import { mapPosVectorFromArgs } from '..'; import { BaseVectorElementStyleBuilder } from './index.common'; export { BaseVectorElementStyleBuilder }; export const BillboardOrientation = { get FACE_CAMERA() { return com.carto.styles.BillboardOrientation.BILLBOARD_ORIENTATION_FACE_CAMERA; }, get FACE_CAMERA_GROUND() { return com.carto.styles.BillboardOrientation.BILLBOARD_ORIENTATION_FACE_CAMERA_GROUND; }, get GROUND() { return com.carto.styles.BillboardOrientation.BILLBOARD_ORIENTATION_GROUND; } }; export const BillboardScaling = { get CONST_SCREEN_SIZE() { return com.carto.styles.BillboardScaling.BILLBOARD_SCALING_CONST_SCREEN_SIZE; }, get SCREEN_SIZE() { return com.carto.styles.BillboardScaling.BILLBOARD_SCALING_SCREEN_SIZE; }, get WORLD_SIZE() { return com.carto.styles.BillboardScaling.BILLBOARD_SCALING_WORLD_SIZE; } }; export class BaseVectorElement extends BaseNative { createNative(options) { return null; } get metaData() { if (this.native) { return nativeMapToJS(this.native.getMetaData()); } else { return this.options.metaData; } } set metaData(value) { this.options.metaData = value; if (this.native) { const theMap = new com.carto.core.StringVariantMap(); for (const key in value) { theMap.set(key, new com.carto.core.Variant(value[key])); } this.native.setMetaData(theMap); } } rebuildStyle() { this.native.setStyle(this.buildStyle()); } } __decorate([ nativeProperty ], BaseVectorElement.prototype, "visible", void 0); export class BasePointVectorElement extends BaseVectorElement { get position() { if (this.native && this.native.getPos) { const nativePos = this.native.getPos(); return fromNativeMapPos(nativePos); } return this.options.position; } set position(pos) { this.options.position = pos; if (this.native && this.native.setPos) { this.native.setPos(this.getNativePos(pos)); } } getNativePos(pos, projection) { return toNativeMapPos(pos); } } export class BaseBillboardVectorElement extends BasePointVectorElement { } __decorate([ nativeProperty ], BaseBillboardVectorElement.prototype, "rotation", void 0); export class BaseLineVectorElement extends BaseVectorElement { get positions() { // if (this.native && this.native.getPoses) { // const nativePos = this.native.getPoses(); // if (this.projection) { // return fromNativeMapPos(this.projection.getNative().toWgs84(nativePos)); // } // return fromNativeMapPos(nativePos); // } return this.options.positions; } set positions(positions) { this.options.positions = positions; if (this.native && this.native.setPoses) { this.native.setPoses(mapPosVectorFromArgs(positions, this.options.ignoreAltitude)); } } } export class VectorElement extends BaseVectorElement { buildStyle() { } } export class VectorElementVector extends BaseNative { constructor() { super(...arguments); this.elements = []; } createNative() { const result = new com.carto.vectorelements.VectorElementVector(); if (this.elements.length > 0) { this.elements.forEach((element) => { result.add(element.getNative()); }); } return result; } getElement(index) { return this.elements[index] || new VectorElement(undefined, this.native.get(index)); } size() { if (this.native) { return this.native.size(); } return this.elements.length; } add(element) { this.elements.push(element); if (this.native) { this.native.add(element.getNative()); } } } export class BillboardStyleBuilder extends BaseVectorElementStyleBuilder { createNative(options) { return null; } dispose() { this.mBuildStyle = null; super.dispose(); } } __decorate([ nativeProperty ], BillboardStyleBuilder.prototype, "scaleWithDPI", void 0); __decorate([ nativeProperty ], BillboardStyleBuilder.prototype, "hideIfOverlapped", void 0); __decorate([ nativeProperty ], BillboardStyleBuilder.prototype, "horizontalOffset", void 0); __decorate([ nativeProperty ], BillboardStyleBuilder.prototype, "verticalOffset", void 0); __decorate([ nativeProperty ], BillboardStyleBuilder.prototype, "animationStyle", void 0); __decorate([ nativeProperty ], BillboardStyleBuilder.prototype, "placementPriority", void 0); __decorate([ nativeProperty ], BillboardStyleBuilder.prototype, "causesOverlap", void 0); __decorate([ nativeProperty ], BillboardStyleBuilder.prototype, "attachAnchorPointX", void 0); __decorate([ nativeProperty ], BillboardStyleBuilder.prototype, "attachAnchorPointY", void 0); //# sourceMappingURL=index.android.js.map