Skip to content

allenhwkim/geo-coder

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Geocoder

Address lookup/autocomplete/reverse-geolookup for Google, OpenStreet, Bing, and OpenCage.

Build Status

  • Small size(2.3K min/gzipped)
  • Working on NodeJS and Browser

Documentation Example

NodeJS Usage

Install

npm install geo-coder --save-dev

Example

global.fetch = require('node-fetch');   // set fetch for nodeJS
var GeoCode = require('geo-coder').GeoCode;

var geoCode = new GeoCode();

// geolookup example
geocode.geolookup('Brampton, Canada').then(result => {
  console.log(result))  //  [ { source: 'OpenStreetMap', lng: -79.752502, lat: 43.715783,..}]
});

// reverse lookup example
geocode.reverse(43.653226, -79.3831843).then(result => {
  console.log(result) // {source: 'OpenStreetMap', address: 'Brampton, ON'...}
});

Browser Usage

Install

Add the library

<script src="https://unpkg.com/geo-coder"></script>

Examples

Default - OpenStreetMap

var geoCode = new GeoCode();

// geolookup example
geoCode.geolookup('Brampton, Canada').then(result => {
  console.log(result);
});

// reverse lookup example
geoCode.reverse(43.653226, -79.3831843).then(result => {
  console.log(result);
});

Google, Bing, OpenCage (keys required)

var googleGeoCode   = new GeoCode('google', { key: 'g0o...' });
var bingGeoCode     = new GeoCode('bing',   { key: 'b1n...' });
var opencageGeoCode = new GeoCode('opencage',   { key: 'op3...' });

NOTE

An API key is required for the following providers.

Google: https://developers.google.com/maps/documentation/javascript/get-api-key

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

OpenCage: https://geocoder.opencagedata.com

About

Geo-Coding/Reverse-Lookup with Various Providers

Resources

License

Stars

Watchers

Forks

Packages

No packages published