Geocoding results according to the GeoJSON specification.
$ npm install --save geocoder-geojsonInstall globaly to access geocode via your command prompt.
$ npm install -g geocoder-geojson
$ geocode --version
$ geocode --helpimport geocoder from 'geocoder-geojson'
geocoder.google('Ottawa, ON')
.then(geojson => console.log(geojson))- Webpack
- Browserify
- ES5 (ES2015)
$ geocode --provider bing "Ottawa ON"
$ geocode -p wikidata --nearest [-75.7,45.4] Ottawa
$ geocode -p google --limit 3 "Ottawa ON"Using jq to filter JSON data
$ geocode -p wikidata --nearest [-75.7,45.4] Ottawa | jq .features[0].id
"Q1930"| Name | Coverage | Restrictions |
|---|---|---|
| Global | Free & API Key - RateLimit 2500/day | |
| googleReverse | Global | Free & API Key - RateLimit 2500/day |
| mapbox | Global | API Key |
| mapboxReverse | Global | API Key |
| bing | Global | API Key |
| wikdata | Global | Free |
- Implement all geocoding providers from
Python Geocoder - Use the
Fetchnative library instead ofaxios
Mapbox Provider
https://www.mapbox.com/api-documentation/#geocoding
Parameters
addressstring Location for your searchoptionsMapboxOptions? Mapbox Optionsoptions.access_tokenstring? Access token or environment variableMAPBOX_ACCESS_TOKENoptions.modestring? Mode mapbox.places or mapbox.places-permanent (optional, default'mapbox.places')options.countrystring? ISO 3166 alpha 2 country codes, separated by commasoptions.proximityLngLat? Location around which to bias results, given as longitude,latitudeoptions.typesArray<string>? Filter results by one or more type.options.autocompleteboolean? Whether or not to return autocomplete results. (optional, defaulttrue)options.bboxBBox? Bounding box within which to limit results, given as minX,minY,maxX,maxYoptions.limitnumber? Limit the number of results returned. (optional, default5)
Examples
const geojson = await geocoder.mapbox('Ottawa, ON')Returns Promise<Points> GeoJSON Point FeatureCollection
Mapbox Provider (Reverse)
https://www.mapbox.com/api-documentation/#geocoding
Parameters
lnglatLngLat Longitude & Latitude [x, y]optionsMapboxOptions? Mapbox Optionsoptions.access_tokenstring? Access token or environment variableMAPBOX_ACCESS_TOKENoptions.modestring? Mode mapbox.places or mapbox.places-permanent (optional, default'mapbox.places')options.countrystring? ISO 3166 alpha 2 country codes, separated by commasoptions.proximityLngLat? Location around which to bias results, given as longitude,latitudeoptions.typesArray<string>? Filter results by one or more type.options.autocompleteboolean? Whether or not to return autocomplete results. (optional, defaulttrue)options.bboxBBox? Bounding box within which to limit results, given as minX,minY,maxX,maxYoptions.limitnumber? Limit the number of results returned. (optional, default1)
Examples
const geojson = await geocoder.mapbox('Ottawa, ON')Returns Promise<Points> GeoJSON Point FeatureCollection
Google Provider
https://developers.google.com/maps/documentation/geocoding
Parameters
addressstring Location for your searchoptionsGoogleOptions? Google Options
Examples
const geojson = await geocoder.google('Ottawa, ON')Returns Promise<Points> GeoJSON Point FeatureCollection
Google Provider (Reverse)
https://developers.google.com/maps/documentation/geocoding
Parameters
lnglatLngLat Longitude & Latitude [x, y]optionsGoogleOptions? Google Options
Examples
const geojson = await geocoder.googleReverse([-75.1, 45.1])Returns Promise<Points> GeoJSON Point FeatureCollection
Bing Provider
https://msdn.microsoft.com/en-us/library/ff701714.aspx
Parameters
addressstring Location for your searchoptionsBingOptions? Bing Options
Examples
const geojson = await geocoder.bing('Ottawa, ON')Returns Promise<Points> GeoJSON Point FeatureCollection
Wikidata Provider
Parameters
addressstring Location for your searchoptionsOptions? Wikidata Options
Examples
const geojson = await geocoder.wikidata('Ottawa')Returns Promise<Points> GeoJSON Point FeatureCollection
Generic GET function to normalize all of the requests
Parameters
urlstring URLgeojsonParserfunction Customized function to generate a GeoJSON Point FeatureCollectionparamsObject Query StringoptionsObject Options used for HTTP request & GeoJSON Parser function
Returns Promise<Points> Results in GeoJSON FeatureCollection Points