1.11.0 • Published 7 years ago

geocoder-geojson v1.11.0

Weekly downloads
10
License
MIT
Repository
github
Last release
7 years ago

Geocoder GeoJSON

Build Status Circle CI Coverage Status npm version MIT licensed

Geocoding results according to the GeoJSON specification.

Install

$ npm install --save geocoder-geojson

Install globaly to access geocode via your command prompt.

$ npm install -g geocoder-geojson
$ geocode --version
$ geocode --help

Quickstart

import geocoder from 'geocoder-geojson'

geocoder.google('Ottawa, ON')
  .then(geojson => console.log(geojson))

Supports

Features

NameCoverageRestrictions
googleGlobalFree & API Key - RateLimit 2500/day
googleReverseGlobalFree & API Key - RateLimit 2500/day
mapboxGlobalAPI Key
mapboxReverseGlobalAPI Key
bingGlobalAPI Key
wikdataGlobalFree

CLI

$ 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"

Roadmap

API

mapbox

Mapbox Provider

https://www.mapbox.com/api-documentation/#geocoding

Parameters

  • address string Location for your search
  • options [MapboxOptions] Mapbox Options
    • options.access_token [string] Access token or environment variable MAPBOX_ACCESS_TOKEN
    • options.mode [string] Mode mapbox.places or mapbox.places-permanent (optional, default 'mapbox.places')
    • options.country [string] ISO 3166 alpha 2 country codes, separated by commas
    • options.proximity [LngLat] Location around which to bias results, given as longitude,latitude
    • options.types [Array<string>] Filter results by one or more type.
    • options.autocomplete [boolean] Whether or not to return autocomplete results. (optional, default true)
    • options.bbox [BBox] Bounding box within which to limit results, given as minX,minY,maxX,maxY
    • options.limit [number] Limit the number of results returned. (optional, default 5)

Examples

const geojson = await geocoder.mapbox('Ottawa, ON')

Returns Promise<Points> GeoJSON Point FeatureCollection

mapboxReverse

Mapbox Provider (Reverse)

https://www.mapbox.com/api-documentation/#geocoding

Parameters

  • lnglat LngLat Longitude & Latitude x, y
  • options [MapboxOptions] Mapbox Options
    • options.access_token [string] Access token or environment variable MAPBOX_ACCESS_TOKEN
    • options.mode [string] Mode mapbox.places or mapbox.places-permanent (optional, default 'mapbox.places')
    • options.country [string] ISO 3166 alpha 2 country codes, separated by commas
    • options.proximity [LngLat] Location around which to bias results, given as longitude,latitude
    • options.types [Array<string>] Filter results by one or more type.
    • options.autocomplete [boolean] Whether or not to return autocomplete results. (optional, default true)
    • options.bbox [BBox] Bounding box within which to limit results, given as minX,minY,maxX,maxY
    • options.limit [number] Limit the number of results returned. (optional, default 1)

Examples

const geojson = await geocoder.mapbox('Ottawa, ON')

Returns Promise<Points> GeoJSON Point FeatureCollection

google

Google Provider

https://developers.google.com/maps/documentation/geocoding

Parameters

  • address string Location for your search
  • options [GoogleOptions] Google Options
    • options.language [string] The language in which to return results (optional, default en)
    • options.short [boolean] Address components have long or short results (optional, default false)

Examples

const geojson = await geocoder.google('Ottawa, ON')

Returns Promise<Points> GeoJSON Point FeatureCollection

googleReverse

Google Provider (Reverse)

https://developers.google.com/maps/documentation/geocoding

Parameters

  • lnglat LngLat Longitude & Latitude x, y
  • options [GoogleOptions] Google Options
    • options.language [string] The language in which to return results (optional, default en)
    • options.short [boolean] Address components have long or short results (optional, default false)

Examples

const geojson = await geocoder.googleReverse([-75.1, 45.1])

Returns Promise<Points> GeoJSON Point FeatureCollection

bing

Bing Provider

https://msdn.microsoft.com/en-us/library/ff701714.aspx

Parameters

  • address string Location for your search
  • options [BingOptions] Bing Options
    • options.key [string] API key or environment variable BING_API_KEY
    • options.maxResults [string] Specifies the maximum number of locations to return in the response.

Examples

const geojson = await geocoder.bing('Ottawa, ON')

Returns Promise<Points> GeoJSON Point FeatureCollection

wikidata

Wikidata Provider

https://query.wikidata.org/

Parameters

  • address string Location for your search
  • options [Options] Wikidata Options
    • options.nearest [LngLat] Nearest location from a given LngLat
    • options.radius [number] Maximum radius from nearest LngLat
    • options.languages [Array<string>] Exact match on a list of languages
    • options.subclasses [Array<string>] Filter results by Wikidata subclasses

Examples

const geojson = await geocoder.wikidata('Ottawa')

Returns Promise<Points> GeoJSON Point FeatureCollection

request

Generic GET function to normalize all of the requests

Parameters

  • url string URL
  • geojsonParser function Customized function to generate a GeoJSON Point FeatureCollection
  • params [Object](default {}) Query String
  • options [Object](default utils.Options) Options used for HTTP request & GeoJSON Parser function

Returns Promise<Points> Results in GeoJSON FeatureCollection Points

1.11.0

7 years ago

1.10.6

7 years ago

1.10.5

7 years ago

1.10.4

7 years ago

1.10.3

7 years ago

1.10.2

7 years ago

1.10.1

7 years ago

1.10.0

7 years ago

1.9.2

7 years ago

1.9.1

7 years ago

1.9.0

7 years ago

1.8.4

7 years ago

1.8.2

7 years ago

1.8.1

7 years ago

1.8.0

7 years ago

1.7.25

7 years ago

1.7.24

7 years ago

1.7.23

7 years ago

1.7.22

7 years ago

1.7.21

7 years ago

1.7.20

7 years ago

1.7.19

7 years ago

1.7.18

7 years ago

1.7.17

7 years ago

1.7.16

7 years ago

1.7.15

7 years ago

1.7.14

7 years ago

1.7.13

7 years ago

1.7.12

7 years ago

1.7.11

7 years ago

1.7.10

7 years ago

1.7.9

7 years ago

1.7.8

7 years ago

1.7.7

7 years ago

1.7.6

7 years ago

1.7.4

7 years ago

1.7.3

7 years ago

1.7.2

7 years ago

1.7.1

7 years ago

1.7.0

7 years ago

1.6.2

7 years ago

1.6.1

7 years ago

1.6.0

7 years ago

1.5.2

8 years ago

1.5.1

8 years ago

1.5.0

8 years ago

1.4.0

8 years ago

1.2.3

8 years ago

1.2.2

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago