roychoo / googleplaces.js

Node.js library for the Google Places API

Home Page:http://srirangan.net/2012-08-googleplaces-js-is-a-node-js-library-for-the-google-places-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

googleplaces.js

A node.js library for the Google Places API

ugh?

googleplaces.js makes it easy to talk to the Google Places API from your server side Node.js application

can i use in the browser?

Google already maintains a dedicated client side JavaScript library

what's supported in 0.3.0?

what's coming up next?

can i contribute?

Yes, fork, hack and send me a PR

get started

1. google

2. npm

$ npm install googleplaces

3. configure

# set environment variables
export GOOGLE_PLACES_API_KEY = "your key here"
export GOOGLE_PLACES_OUTPUT_FORMAT = "json"

examples

places search

var config = require("./config.js");

var GooglePlaces = require("googleplaces");
var googlePlaces = new GooglePlaces(process.env.GOOGLE_PLACES_API_KEY, process.env.GOOGLE_PLACES_OUTPUT_FORMAT);
var parameters;

/**
 * Place search - https://developers.google.com/places/documentation/#PlaceSearchRequests
 */
parameters = {
  location:[-33.8670522, 151.1957362],
  types:"doctor"
};
googlePlaces.placeSearch(parameters, function (error, response) {
  if (error) throw error;
  console.log(response.results);
});

places details

var config = require("./config.js");

var GooglePlaces = require("googleplaces");
var googlePlaces = new GooglePlaces(process.env.GOOGLE_PLACES_API_KEY, process.env.GOOGLE_PLACES_OUTPUT_FORMAT);
var parameters;

/**
 * Place details requests - https://developers.google.com/places/documentation/#PlaceDetails
 */
parameters = {
  location:[-33.8670522, 151.1957362],
  types:"doctor"
};
googlePlaces.placeSearch(parameters, function (error, response) {
  if (error) throw error;
  googlePlaces.placeDetailsRequest({reference:response.results[0].reference}, function (error, response) {
    if (error) throw error;
    console.log(response.result);
  });
});

text search

var config = require("./config.js");

var GooglePlaces = require("googleplaces");
var googlePlaces = new GooglePlaces(process.env.GOOGLE_PLACES_API_KEY, process.env.GOOGLE_PLACES_OUTPUT_FORMAT);
var parameters;

/**
 * Text search - https://developers.google.com/places/documentation/#TextSearchRequests
 */
parameters = {
  query:"restaurants in dublin"
};
googlePlaces.textSearch(parameters, function (error, response) {
  if (error) throw error;
  console.log(response.results);
});

About

Node.js library for the Google Places API

http://srirangan.net/2012-08-googleplaces-js-is-a-node-js-library-for-the-google-places-api


Languages

Language:JavaScript 99.0%Language:Shell 1.0%