A simple way to query the Google Maps API from Node.js
This was a quick hack to work with Node.js. Criticism/Suggestions/Patches/PullReq's welcome.
curl http://npmjs.org/install.sh | sh
npm install googlemaps
APIs implemented:
- Geocoding
- Directions
- Elevation
- Places (thx evnm)
TODO:
- Static Maps
- Tests for everything (using vows)
var gm = require('googlemaps');
var sys = require('sys');
gm.reverseGeocode('41.850033,-87.6500523', function(err, data){
sys.puts(JSON.stringify(data));
});
gm.reverseGeocode(gm.checkAndConvertPoint([41.850033, -87.6500523]), function(err, data){
sys.puts(JSON.stringify(data));
});
Both examples print: {"status":"OK","results":[{"types":["postal_code"],"formatted_address":"Chicago, IL 60695, USA"...
All the googlemaps functions follow this scheme: function(required, callback, optional)
All callbacks are expected to follow: function(error, results) Where the error returned is an Error object.
Please refer to the code, tests and the Google Maps API docs for further usage information.