@nativescript-community/ui-carto
Version:
NativeScript plugin for CARTO Mobile SDK
65 lines • 2.2 kB
JavaScript
import { geometryFromArgs, nativeColorProperty, nativeProperty } from '..';
import { BasePointVectorElement } from './index.android';
import { BaseVectorElementStyleBuilder, styleBuilderProperty } from './index.common';
export class PointStyleBuilder extends BaseVectorElementStyleBuilder {
createNative(options) {
return new com.carto.styles.PointStyleBuilder();
}
buildStyle() {
if (!this.mBuildStyle) {
this.mBuildStyle = this.getNative().buildStyle();
}
return this.mBuildStyle;
}
}
__decorate([
nativeProperty
], PointStyleBuilder.prototype, "size", void 0);
__decorate([
nativeColorProperty
], PointStyleBuilder.prototype, "color", void 0);
__decorate([
nativeProperty
], PointStyleBuilder.prototype, "clickSize", void 0);
export class Point extends BasePointVectorElement {
createNative(options) {
const style = this.buildStyle();
const nativePos = this.getNativePos(options.position, options.projection);
return new com.carto.vectorelements.Point(nativePos, style);
}
buildStyle() {
let style;
const styleBuilder = this.options.styleBuilder;
if (styleBuilder instanceof com.carto.styles.PointStyle) {
style = styleBuilder;
}
else if (styleBuilder instanceof PointStyleBuilder) {
style = styleBuilder.buildStyle();
}
else if (styleBuilder.hasOwnProperty) {
style = new PointStyleBuilder(styleBuilder).buildStyle();
}
return style;
}
get styleBuilder() {
return this.native ? this.native.getStyle() : this.options.styleBuilder;
}
set styleBuilder(value) {
if (this.native && !this.duringInit) {
this.options.styleBuilder = value;
this.native.setStyle(this.buildStyle());
}
}
set geometry(geometry) {
if (this.native) {
this.native.setGeometry(geometryFromArgs(geometry));
}
}
}
__decorate([
styleBuilderProperty
], Point.prototype, "color", void 0);
__decorate([
styleBuilderProperty
], Point.prototype, "size", void 0);
//# sourceMappingURL=point.android.js.map