Socket
Socket
Sign inDemoInstall

geocoder

Package Overview
Dependencies
50
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    geocoder

node wrapper around google's geocoder api


Version published
Weekly downloads
1.9K
decreased by-32.06%
Maintainers
1
Install size
4.18 MB
Created
Weekly downloads
 

Readme

Source

Geocoder

###Installation:

npm install geocoder

Usage

You can pass a string representation of a location and a callback function to geocoder.geocode. It will accept anything that Google will accept: cities, streets, countries, etc.

###Example:

var geocoder = require('geocoder');

// Geocoding
geocoder.geocode("Atlanta, GA", function ( err, data ) {
  // do something with data
});

// Reverse Geocoding
geocoder.reverseGeocode( 33.7489, -84.3789, function ( err, data ) {
  // do something with data
});

// Setting sensor to true
geocoder.reverseGeocode( 33.7489, -84.3789, function ( err, data ) {
  // do something with data
}, { sensor: true });

// Setting language to German
geocoder.reverseGeocode( 33.7489, -84.3789, function ( err, data ) {
  // do something with data
}, { language: 'de' });


// Selecting another provider to do reverse geocoding
// Currently only geonames and yahoo placefinder are supported
geocoder.selectProvider("geonames",{"username":"demo"});

// Output will be roughly in the same format as Google's
geocoder.reverseGeocode( 33.7489, -84.3789, function ( err, data ) {
  // do something with data
});

// see http://developer.yahoo.com/geo/placefinder/guide/index.html
geocoder.selectProvider("yahoo",{"appid":"xxx"});

// Output will be roughly in the same format as Google's
geocoder.reverseGeocode( 33.7489, -84.3789, function ( err, data ) {
  // do something with data
});





Results will look like standard Google JSON Output

You can pass in an optional options hash as a last argument, useful for setting sensor to true (it defaults to false) and the language (default is empty which means that google geocoder will guess it by geo ip data). For details see the Google Geocoding API Docs

###Testing: nodeunit test

Roadmap

  • Complete Test Suite
  • Better options handling

Further Reading

Keywords

FAQs

Last updated on 23 Mar 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc