address-complete
What are you looking for? Or how?
Address-complete provide unified way to perform address autocomplete using 3 geo-data providers:
- Google autocomplete + places API
- MapZen (Pelias) autocomplete API
- Yandex Geocoder
This library provides both basic address autocompete features, and extended address details extraction to enable complex forms to shine.
Setup
npm install address-autocomplete
API
%provider_name%.search(term): Promise %provider_name%.getDetails(term): Promise
MAPZEN all the things.
Nor google, nor yandex will NOT work in browser due to CORS limitations.
Use mapzen instead.
Example
there is live example at codesandbox - https://codesandbox.io/s/y382k7n61j
;;; // Google and MapZen does require an API key;configure'YOUR_API_KEY'; mapzen.search'something'.thenasync
PS: To say they truth - you have to call getDetails only for Google API. All other API just mimic Google's behavior.
mapzen
google
Types
This library comes with TS and Flow definition, but anyway
Response from Google.search is AddressResponse
Response and any other API, or from google.getDetails
Country list
Hey! How to get list of countries or list of states for a country?
Just use iso3166-2-db
;
address complete uses iso3166-2-db to extract iso3166-2 regions names from MapZen answers.
Which API to use?
I could recommend:
- MapZen - it is almost free, and high quality.
- Google is a standard defacto.
- Yandex, for Europe.
License
MIT