Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@geoapify/geocoder-autocomplete

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@geoapify/geocoder-autocomplete - npm Package Compare versions

Comparing version 1.1.2 to 1.2.0

4

dist/autocomplete.d.ts

@@ -10,2 +10,3 @@ export declare class GeocoderAutocomplete {

private currentPromiseReject;
private currentPlaceDetailsPromiseReject;
private currentTimeout;

@@ -15,2 +16,3 @@ private changeCallbacks;

private geocoderUrl;
private placeDetailsUrl;
private options;

@@ -51,2 +53,3 @@ private BY_COUNTRYCODE;

private openDropdownAgain;
private generatePlacesUrlUrl;
private generateUrl;

@@ -68,2 +71,3 @@ private isLatitude;

skipIcons?: boolean;
skipDetails?: boolean;
position?: GeoPosition;

@@ -70,0 +74,0 @@ countryCodes?: CountyCode[];

@@ -6,2 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.GeocoderAutocomplete = void 0;
const countries_json_1 = __importDefault(require("./countries.json"));

@@ -16,2 +17,3 @@ class GeocoderAutocomplete {

this.geocoderUrl = "https://api.geoapify.com/v1/geocode/autocomplete";
this.placeDetailsUrl = "https://api.geoapify.com/v2/place-details";
this.options = {

@@ -363,3 +365,40 @@ limit: 5

notifyValueSelected(feature) {
this.changeCallbacks.forEach(callback => callback(feature));
// Cancel previous place details request
if (this.currentPlaceDetailsPromiseReject) {
this.currentPlaceDetailsPromiseReject({
canceled: true
});
this.currentPlaceDetailsPromiseReject = null;
}
if (this.options.skipDetails || !feature) {
this.changeCallbacks.forEach(callback => callback(feature));
}
else {
const promise = new Promise((resolve, reject) => {
this.currentPlaceDetailsPromiseReject = reject;
let url = this.generatePlacesUrlUrl(feature.properties.place_id);
fetch(url)
.then((response) => {
if (response.ok) {
response.json().then(data => resolve(data));
}
else {
response.json().then(data => reject(data));
}
});
});
promise.then((data) => {
if (!data.features.length) {
this.changeCallbacks.forEach(callback => callback(feature));
return;
}
const placeDetails = data.features[0];
this.changeCallbacks.forEach(callback => callback(placeDetails));
this.currentPlaceDetailsPromiseReject = null;
}, (err) => {
if (!err.canceled) {
console.log(err);
}
});
}
}

@@ -374,2 +413,5 @@ notifySuggestions(features) {

}
generatePlacesUrlUrl(placeId) {
return `${this.placeDetailsUrl}?id=${placeId}&apiKey=${this.apiKey}`;
}
generateUrl(value) {

@@ -376,0 +418,0 @@ let url = `${this.geocoderUrl}?text=${encodeURIComponent(value)}&apiKey=${this.apiKey}`;

3

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GeocoderAutocomplete = void 0;
var autocomplete_1 = require("./autocomplete");
exports.GeocoderAutocomplete = autocomplete_1.GeocoderAutocomplete;
Object.defineProperty(exports, "GeocoderAutocomplete", { enumerable: true, get: function () { return autocomplete_1.GeocoderAutocomplete; } });
{
"name": "@geoapify/geocoder-autocomplete",
"version": "1.1.2",
"version": "1.2.0",
"description": "Geocoder autocomplete field",

@@ -24,3 +24,6 @@ "main": "dist/index.js",

"amenity",
"location"
"location",
"regions",
"boundaries",
"place details"
],

@@ -38,4 +41,4 @@ "author": {

"devDependencies": {
"typescript": "^3.4.3"
"typescript": "^4.0.5"
}
}

@@ -6,4 +6,8 @@ # Geoapify Geocoder Autocomplete

* shows place suggestions in a dropdown list;
* notify about suggestions change and selection.
* notifies on suggestions change;
* makes a call to Place Details API to get more information and geometry on user selection if is not skipped;
* notifies on selection change. Returns [Geocoding API](https://apidocs.geoapify.com/docs/geocoding/api/api) object or [Place Details API object](https://apidocs.geoapify.com/docs/place-details/feature/details-feature) depending on options set.
The library makes a call to [Geoapify Place Details API](https://apidocs.geoapify.com/docs/place-details) on user select events. The API lets to get detailed information about the place selected as well as place category and place geometry (building polygon or region boundary). Note, that the Place Details API call costs an additional 'geocoding & places' request. Use the `skipDetails` option to switch the functionality off.
You can also:

@@ -80,2 +84,3 @@ * specify a location type - **country**, **state**, **city**, **postcode**, **street**, **amenity**;

| skipIcons | boolean | Don't add icons to suggestions |
| skipDetails | boolean | Skip Place Details API call on selection change |
| filter | FilterOptions | Filter places by country, boundary, circle |

@@ -82,0 +87,0 @@ | bias | BiasOptions | Prefer places by country, boundary, circle, location |

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc