Skip to content
A simple way to query the Google Maps API from Node.js
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Google Maps API for Node.js

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.


Installing npm (node package manager)

curl | sh

Installing googlemaps

npm install googlemaps


APIs implemented:



var gm = require('googlemaps');
var sys = require('sys');

gm.reverseGeocode('41.850033,-87.6500523', function(err, data){

gm.reverseGeocode(gm.checkAndConvertPoint([41.850033, -87.6500523]), function(err, data){

Both examples print: {"status":"OK","results":[{"types":["postal_code"],"formatted_address":"Chicago, IL 60695, USA"...

For the Static Maps API, you can pass in all the required parameters as well as markers, styles, and paths using the formats outlined below.

markers = [
    { 'location': '300 W Main St Lock Haven, PA' },
    { 'location': '444 W Main St Lock Haven, PA',
        'color': 'red',
        'label': 'A',
        'shadow': 'false',
        'icon' : ''

styles = [
    { 'feature': 'road', 'element': 'all', 'rules': 
        { 'hue': '0x00ff00' }

paths = [
    { 'color': '0x0000ff', 'weight': '5', 'points': 
        [ '41.139817,-77.454439', '41.138621,-77.451596' ]

sys.puts(gm.staticMap('444 W Main St Lock Haven PA', 15, '500x400', false, false, 'roadmap', markers, styles, paths));

This example prints the URL for the Static Map image: ""

By giving gm.staticMap an optional callback, you can retreive the static map PNG data:

sys.puts(gm.staticMap('444 W Main St Lock Haven PA', 15, '500x400', function(err, data){
  require('fs').writeFileSync('test_map.png', data, 'binary');
}, false, 'roadmap', markers, styles, paths));

You will get a map like:

Some Map

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.


evnm duncanm sugendran JoshSmith

Something went wrong with that request. Please try again.