UNPKG

@nativescript-community/ui-carto

Version:

NativeScript plugin for CARTO Mobile SDK

95 lines 3.75 kB
import { nativeProperty, nativeStringListProperty } from '../index.common'; import { BaseNative } from '../BaseNative'; import { FeatureCollection, VectorTileFeatureCollection } from '../geometry/feature'; import { toNativeMapPos } from '../core'; import { geometryFromArgs } from '..'; export class VectorTileSearchService extends BaseNative { createNative(options) { if (options.layer) { const layer = options.layer.getNative(); return AKVectorTileSearchService.alloc().initWithDataSourceTileDecoder(layer.getDataSource(), layer.getTileDecoder()); } else { return AKVectorTileSearchService.alloc().initWithDataSourceTileDecoder(options.dataSource.getNative(), options.decoder.getNative()); } } findFeatures(options, callback) { const nRequest = NTSearchRequest.alloc().init(); 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)); } if (callback) { this.getNative().findFeaturesCallback(nRequest, (r) => new VectorTileFeatureCollection(r)); return null; } else { 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 AKFeatureCollectionSearchService.alloc().initWithProjectionFeatureCollection(options.projection.getNative(), options.features.getNative()); } findFeatures(options, callback) { const nRequest = NTSearchRequest.alloc().init(); 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(NTPointGeometry.alloc().initWithPos(toNativeMapPos(options.position))); } } if (callback) { this.getNative().findFeaturesCallback(nRequest, (r) => new FeatureCollection(r)); return null; } else { return new FeatureCollection(this.getNative().findFeatures(nRequest)); } } } //# sourceMappingURL=index.ios.js.map