googleplaces-promises
Based on IMO the best google places module created by Srirangan - googleplaces
Usage:
$npm install googleplaces-promises
then:
var GooglePlacesPromises = ;
API setup:
Constructor takes 2 arguments API_KEY and OUTPUT_TYPE (not required, default is json)
var placesPromises = 'YOUR_API_KEY'; //OR var placesPromises = GooglePlacesPromises; //every next require('googleplaces-promises').API on app scope will be your default API//useful when you are going to use module multiple times in one app //placesPromises == GooglePlacesPromises.API // true//placesPromises instanceof GooglePlacesPromises //true
Single promise:
var searchParams = location: 407127 -740059 types: "doctor" placeSearch = placesPromises; placeSearch
Parallel execution example:
var Q = placeSearchParams = location: 407127 -740059 types: "doctor" textSearchParams = query: 'restaurants in dublin' placeSearch = placesPromises textSearch = placesPromises promises = placeSearch textSearch; Qallpromises ;
Implemented methods
GooglePlacesPromises module
- new GooglePlacesPromises(API_KEY, OUTPUT_FORMAT) - returning wrapped googleplaces
- GooglePlacesPromises.setDefaultAPI(API_KEY, OUTPUT_FORMAT) - setting new GooglePlacesPromises(*args) as:
- GooglePlacesPromises.API - default API if set.
GooglePlacesPromises instance
instance has the same methods as googleplaces'
- placesPromises.placeSearch(params)
- placesPromises.radarSearch(params)
- placesPromises.textSearch(params)
- placesPromises.placeDetailsRequest(params)
- placesPromises.placeAutocomplete(params)
- placesPromises.addEvent(params)
- placesPromises.deleteEvent(params)
- placesPromises.eventDetails(params)
- placesPromises.imageFetch(params)
Run test.js
But first paste you api key inside test.js