diff --git a/src/ui-carto/ui/cssproperties.ts b/src/ui-carto/ui/cssproperties.ts index bc67d1eb..35be7e74 100644 --- a/src/ui-carto/ui/cssproperties.ts +++ b/src/ui-carto/ui/cssproperties.ts @@ -1,6 +1,5 @@ import { CssProperty, Style, booleanConverter } from '@nativescript/core'; -import { LatitudeKey, LongitudeKey } from '../core'; -import { GenericMapPos } from '../core/index.common'; +import { GenericMapPos, LatitudeKey, LongitudeKey } from '../core'; export const zoomProperty = new CssProperty({ name: 'zoom', diff --git a/src/ui-carto/vectorelements/group.d.ts b/src/ui-carto/vectorelements/group.d.ts index 8b615224..e93a9537 100644 --- a/src/ui-carto/vectorelements/group.d.ts +++ b/src/ui-carto/vectorelements/group.d.ts @@ -1,7 +1,6 @@ import { BasePointVectorElement, PointVectorElementOptions, VectorElement, VectorElementVector } from '.'; -import { MapPos } from '../core'; +import { DefaultLatLonKeys, GenericMapPos, MapPos } from '../core'; import { Projection } from '../projections'; -import { DefaultLatLonKeys, GenericMapPos } from '../core/index.common'; export class GroupOptions extends PointVectorElementOptions { elements: { id: string; element: VectorElement }[]; diff --git a/src/ui-carto/vectorelements/index.android.ts b/src/ui-carto/vectorelements/index.android.ts index dc03d9db..4bd428a7 100644 --- a/src/ui-carto/vectorelements/index.android.ts +++ b/src/ui-carto/vectorelements/index.android.ts @@ -2,9 +2,9 @@ import { AnimationStyle, BillboardStyleBuilderOptions, LineVectorElementOptions, // import { BaseVectorElement } from './vectorelements.common'; import { nativeProperty } from '../index.common'; import { BaseNative } from '../BaseNative'; -import { nativeMapToJS } from '../utils'; +import { JSVariantToNative, nativeMapToJS, nativeVariantToJS } from '../utils'; import { Projection } from '../projections'; -import { MapPos, MapPosVector, fromNativeMapPos, toNativeMapPos } from '../core'; +import { MapPos, MapPosVector, fromNativeMapBounds, fromNativeMapPos, toNativeMapPos } from '../core'; import { mapPosVectorFromArgs } from '..'; import { BaseVectorElementStyleBuilder } from './index.common'; export { BaseVectorElementStyleBuilder }; @@ -38,24 +38,26 @@ export abstract class BaseVectorElement { + @nativeProperty id: number; + + containsMetaDataKey(key: string): boolean { + return this.native ? this.native.containsMetaDataKey(key) : false; + } + getMetadataElement(key: string): { [k: string]: string } { + if (this.native) { + return nativeVariantToJS(this.native.getMetaDataElement(key)); + } + return undefined; + } + setMetadataElement(key: string, element: { [k: string]: string }): void { + if (this.native) { + this.native.setMetaDataElement(key, JSVariantToNative(element)); + } + } + getGeometry() { + return this.getNative().getGeometry(); + } + getBounds() { + return fromNativeMapBounds(this.getNative().getBounds()); + } + buildStyle() {} } diff --git a/src/ui-carto/vectorelements/index.d.ts b/src/ui-carto/vectorelements/index.d.ts index 9d6fde94..47d923bc 100644 --- a/src/ui-carto/vectorelements/index.d.ts +++ b/src/ui-carto/vectorelements/index.d.ts @@ -1,7 +1,7 @@ import { BaseNative } from '..'; -import { MapPos, MapPosVector } from '../core'; +import { DefaultLatLonKeys, GenericMapPos, MapBounds, MapPos, MapPosVector } from '../core'; import { Projection } from '../projections'; -import { DefaultLatLonKeys, GenericMapPos } from '../core/index.common'; +import { Geometry } from '../geometry'; declare enum BillboardOrientation { FACE_CAMERA, @@ -70,7 +70,13 @@ export abstract class BaseLineVectorElement | GenericMapPos[]; projection?: Projection; } -export class VectorElement extends BaseVectorElement {} +export class VectorElement extends BaseVectorElement { + id?: number; + getBounds(): MapBounds; + getGeometry(): Geometry; + getMetadataElement(key: string): { [k: string]: string }; + setMetadataElement(key: string, element: { [k: string]: string }): void; +} export abstract class BaseVectorElementStyleBuilder extends BaseNative { buildStyle(): any; } diff --git a/src/ui-carto/vectorelements/index.ios.ts b/src/ui-carto/vectorelements/index.ios.ts index 95b03ce6..9b128de2 100644 --- a/src/ui-carto/vectorelements/index.ios.ts +++ b/src/ui-carto/vectorelements/index.ios.ts @@ -1,9 +1,9 @@ import { AnimationStyle, BillboardStyleBuilderOptions, LineVectorElementOptions, PointVectorElementOptions, VectorElementOptions } from '.'; import { nativeProperty } from '../index.common'; import { BaseNative } from '../BaseNative'; -import { nativeMapToJS } from '../utils'; +import { JSVariantToNative, nativeMapToJS, nativeVariantToJS } from '../utils'; import { Projection } from '../projections'; -import { MapPos, MapPosVector, fromNativeMapPos, toNativeMapPos } from '../core'; +import { MapPos, MapPosVector, fromNativeMapBounds, fromNativeMapPos, toNativeMapPos } from '../core'; import { mapPosVectorFromArgs } from '..'; import { BaseVectorElementStyleBuilder } from './index.common'; export { BaseVectorElementStyleBuilder }; @@ -37,24 +37,26 @@ export abstract class BaseVectorElement { + @nativeProperty id: number; + + containsMetaDataKey(key: string): boolean { + return this.native ? this.native.containsMetaDataKey(key) : false; + } + getMetadataElement(key: string): { [k: string]: string } { + if (this.native) { + return nativeVariantToJS(this.native.getMetaDataElement(key)); + } + return undefined; + } + setMetadataElement(key: string, element: { [k: string]: string }): void { + if (this.native) { + this.native.setMetaDataElementElement(key, JSVariantToNative(element)); + } + } + getGeometry() { + return this.getNative().getGeometry(); + } + getBounds() { + return fromNativeMapBounds(this.getNative().getBounds()); + } + buildStyle() {} } export class VectorElementVector extends BaseNative { diff --git a/src/ui-carto/vectorelements/line.android.ts b/src/ui-carto/vectorelements/line.android.ts index 3e6e27a5..378727f0 100644 --- a/src/ui-carto/vectorelements/line.android.ts +++ b/src/ui-carto/vectorelements/line.android.ts @@ -1,5 +1,5 @@ import { Color } from '@nativescript/core'; -import { geometryFromArgs, mapPosVectorFromArgs, nativeAndroidEnumProperty, nativeColorProperty, nativeProperty } from '..'; +import { geometryFromArgs, mapPosVectorFromArgs, nativeColorProperty, nativeProperty } from '..'; import { MapBounds, MapPos, MapPosVector, fromNativeMapBounds } from '../core'; import { LineGeometry } from '../geometry'; import { BaseLineVectorElement } from './index.android'; @@ -115,18 +115,20 @@ export class Line extends BaseLineVectorElement { getPoses() { return this.positions; } + get geometry(): NTLineGeometry { + return this.getGeometry(); + } set geometry(geometry: LineGeometry) { if (this.native) { this.native.setGeometry(geometryFromArgs(geometry)); @@ -132,7 +135,6 @@ export class Line extends BaseLineVectorElement { return this.getNative().getGeometry(); } getBounds() { - const nBounds = this.getNative().getBounds(); - return fromNativeMapBounds(nBounds); + return fromNativeMapBounds(this.getNative().getBounds()); } }