@nativescript-community/ui-carto
Version:
NativeScript plugin for CARTO Mobile SDK
102 lines • 4.16 kB
JavaScript
import { nativeProperty, nativeStringListProperty } from '../index.common';
import { BaseNative } from '../BaseNative';
import { toNativeMapPos } from '../core';
import { FeatureCollection, VectorTileFeatureCollection } from '../geometry/feature';
import { geometryFromArgs } from '..';
export class VectorTileSearchService extends BaseNative {
createNative(options) {
if (options.layer) {
const layer = options.layer.getNative();
return new com.akylas.carto.additions.AKVectorTileSearchService(layer.getDataSource(), layer.getTileDecoder());
}
else {
return new com.akylas.carto.additions.AKVectorTileSearchService(options.dataSource.getNative(), options.decoder.getNative());
}
}
findFeatures(options, callback) {
const nRequest = new com.carto.search.SearchRequest();
if (options.projection) {
nRequest.setProjection(options.projection.getNative());
}
if (options.searchRadius !== undefined) {
nRequest.setSearchRadius(options.searchRadius);
}
if (options.filterExpression !== undefined) {
nRequest.setFilterExpression(options.filterExpression);
}
if (options.regexFilter !== undefined) {
nRequest.setRegexFilter(options.regexFilter);
}
if (options.geometry) {
nRequest.setGeometry(geometryFromArgs(options.geometry));
}
else if (options.position) {
nRequest.setGeometry(new com.carto.geometry.PointGeometry(toNativeMapPos(options.position)));
}
if (callback) {
this.getNative().findFeaturesCallback(nRequest, new com.akylas.carto.additions.VectorTileSearchServiceCallback({
onFindFeatures(res) {
callback(new VectorTileFeatureCollection(res));
}
}));
return null;
}
return new VectorTileFeatureCollection(this.getNative().findFeatures(nRequest));
}
}
__decorate([
nativeProperty
], VectorTileSearchService.prototype, "minZoom", void 0);
__decorate([
nativeProperty
], VectorTileSearchService.prototype, "maxZoom", void 0);
__decorate([
nativeProperty
], VectorTileSearchService.prototype, "maxResults", void 0);
__decorate([
nativeProperty
], VectorTileSearchService.prototype, "sortByDistance", void 0);
__decorate([
nativeProperty
], VectorTileSearchService.prototype, "preventDuplicates", void 0);
__decorate([
nativeStringListProperty
], VectorTileSearchService.prototype, "layers", void 0);
export class FeatureCollectionSearchService extends BaseNative {
createNative(options) {
return new com.akylas.carto.additions.AKFeatureCollectionSearchService(options.projection.getNative(), options.features.getNative());
}
findFeatures(options, callback) {
const nRequest = new com.carto.search.SearchRequest();
if (options.projection) {
nRequest.setProjection(options.projection.getNative());
}
if (options.searchRadius !== undefined) {
nRequest.setSearchRadius(options.searchRadius);
}
if (options.filterExpression !== undefined) {
nRequest.setFilterExpression(options.filterExpression);
}
if (options.regexFilter !== undefined) {
nRequest.setRegexFilter(options.regexFilter);
}
if (options.geometry) {
nRequest.setGeometry(options.geometry);
}
else {
if (options.position) {
nRequest.setGeometry(new com.carto.geometry.PointGeometry(toNativeMapPos(options.position)));
}
}
if (callback) {
this.getNative().findFeaturesCallback(nRequest, new com.akylas.carto.additions.FeatureCollectionSearchServiceCallback({
onFindFeatures(res) {
callback(new VectorTileFeatureCollection(res));
}
}));
return null;
}
return new FeatureCollection(this.getNative().findFeatures(nRequest));
}
}
//# sourceMappingURL=index.android.js.map