UNPKG

@nativescript-community/ui-carto

Version:

NativeScript plugin for CARTO Mobile SDK

185 lines 6.99 kB
import { toNativeMapPos } from '../core'; import { FeatureCollection } from '../geometry/feature'; import { nativeProperty } from '..'; import { BaseGeocodingService } from './service.common'; import { BaseNative } from '../BaseNative'; import { NativeVector } from '../core/index.android'; export class GeocodingService extends BaseGeocodingService { calculateAddresses(options, callback) { const nRequest = new com.carto.geocoding.GeocodingRequest(options.projection.getNative(), options.query); if (options.locationRadius !== undefined) { nRequest.setLocationRadius(options.locationRadius); } if (options.location) { nRequest.setLocation(toNativeMapPos(options.location)); } com.akylas.carto.additions.AKGeocodingServiceAdditions.calculateAddress(this.getNative(), nRequest, new com.akylas.carto.additions.GeocodingServiceAddressCallback({ onGeoCodingResult(err, res) { callback(err, res ? new GeocodingResultVector(res) : null); } })); } } export class ReverseGeocodingService extends BaseGeocodingService { calculateAddresses(options, callback) { const nRequest = new com.carto.geocoding.ReverseGeocodingRequest(options.projection.getNative(), toNativeMapPos(options.location)); if (options.searchRadius !== undefined) { nRequest.setSearchRadius(options.searchRadius); } com.akylas.carto.additions.AKGeocodingServiceAdditions.calculateAddress(this.getNative(), nRequest, new com.akylas.carto.additions.GeocodingServiceAddressCallback({ onGeoCodingResult(err, res) { callback(err, res ? new GeocodingResultVector(res) : null); } })); } } export class GeocodingResult extends BaseNative { constructor(native) { super(null, native); } getAddress() { return this.native.getAddress(); // return { // street: nResult.getStreet(), // country: nResult.getCountry(), // name: nResult.getName(), // neighbourhood: nResult.getNeighbourhood(), // postcode: nResult.getPostcode(), // houseNumber: nResult.getHouseNumber(), // region: nResult.getRegion(), // locality: nResult.getLocality(), // categories: nativeVectorToArray(nResult.getCategories()) // } as Address; } getRank() { return this.native.getRank(); } getFeatureCollection() { return new FeatureCollection(this.native.getFeatureCollection()); } } export class GeocodingResultVector extends NativeVector { get(index) { return new GeocodingResult(this.native.get(index)); } } export class PeliasOnlineGeocodingService extends GeocodingService { createNative(options) { return new com.carto.geocoding.PeliasOnlineGeocodingService(options.apiKey); } } __decorate([ nativeProperty ], PeliasOnlineGeocodingService.prototype, "autocomplete", void 0); __decorate([ nativeProperty ], PeliasOnlineGeocodingService.prototype, "language", void 0); __decorate([ nativeProperty ], PeliasOnlineGeocodingService.prototype, "customServiceURL", void 0); export class PeliasOnlineReverseGeocodingService extends ReverseGeocodingService { createNative(options) { return new com.carto.geocoding.PeliasOnlineReverseGeocodingService(options.apiKey); } } __decorate([ nativeProperty ], PeliasOnlineReverseGeocodingService.prototype, "language", void 0); __decorate([ nativeProperty ], PeliasOnlineReverseGeocodingService.prototype, "customServiceURL", void 0); export class TomTomOnlineGeocodingService extends GeocodingService { createNative(options) { return new com.carto.geocoding.TomTomOnlineGeocodingService(options.apiKey); } } __decorate([ nativeProperty ], TomTomOnlineGeocodingService.prototype, "autocomplete", void 0); __decorate([ nativeProperty ], TomTomOnlineGeocodingService.prototype, "language", void 0); __decorate([ nativeProperty ], TomTomOnlineGeocodingService.prototype, "customServiceURL", void 0); export class TomTomOnlineReverseGeocodingService extends ReverseGeocodingService { createNative(options) { return new com.carto.geocoding.TomTomOnlineReverseGeocodingService(options.apiKey); } } __decorate([ nativeProperty ], TomTomOnlineReverseGeocodingService.prototype, "language", void 0); __decorate([ nativeProperty ], TomTomOnlineReverseGeocodingService.prototype, "customServiceURL", void 0); export class MapBoxOnlineGeocodingService extends GeocodingService { createNative(options) { return new com.carto.geocoding.MapBoxOnlineGeocodingService(options.apiKey); } } __decorate([ nativeProperty ], MapBoxOnlineGeocodingService.prototype, "autocomplete", void 0); __decorate([ nativeProperty ], MapBoxOnlineGeocodingService.prototype, "language", void 0); __decorate([ nativeProperty ], MapBoxOnlineGeocodingService.prototype, "customServiceURL", void 0); export class MapBoxOnlineReverseGeocodingService extends ReverseGeocodingService { createNative(options) { return new com.carto.geocoding.MapBoxOnlineReverseGeocodingService(options.apiKey); } } __decorate([ nativeProperty ], MapBoxOnlineReverseGeocodingService.prototype, "language", void 0); __decorate([ nativeProperty ], MapBoxOnlineReverseGeocodingService.prototype, "customServiceURL", void 0); export class OSMOfflineGeocodingService extends GeocodingService { createNative(options) { return new com.carto.geocoding.OSMOfflineGeocodingService(options.path); } } __decorate([ nativeProperty ], OSMOfflineGeocodingService.prototype, "autocomplete", void 0); __decorate([ nativeProperty ], OSMOfflineGeocodingService.prototype, "language", void 0); __decorate([ nativeProperty ], OSMOfflineGeocodingService.prototype, "maxResults", void 0); export class OSMOfflineReverseGeocodingService extends ReverseGeocodingService { createNative(options) { return new com.carto.geocoding.OSMOfflineReverseGeocodingService(options.path); } } __decorate([ nativeProperty ], OSMOfflineReverseGeocodingService.prototype, "language", void 0); export class MultiOSMOfflineGeocodingService extends GeocodingService { createNative(options) { return new com.carto.geocoding.MultiOSMOfflineGeocodingService(); } add(database) { this.getNative().add(database); } remove(database) { this.getNative().remove(database); } } export class MultiOSMOfflineReverseGeocodingService extends ReverseGeocodingService { createNative(options) { return new com.carto.geocoding.MultiOSMOfflineReverseGeocodingService(); } add(database) { this.getNative().add(database); } remove(database) { this.getNative().remove(database); } } //# sourceMappingURL=service.android.js.map