Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var places = new GooglePlaces('YOUR_API_KEY');
places.search({keyword: 'Vermonster'}, function(err, response) {
console.log("search: ", response.results);

places.details({reference: response.results[0].reference}, function(err, response) {
places.details({placeid: response.results[0].place_id}, function(err, response) {
console.log("search details: ", response.result.website);
// search details: http://www.vermonster.com/
});
Expand All @@ -37,7 +37,7 @@ places.autocomplete({input: 'Verm', types: "(cities)"}, function(err, response)
};

for(var index in response.predictions) {
places.details({reference: response.predictions[index].reference}, success);
places.details({placeid: response.predictions[index].place_id}, success);
}
});
```
Expand Down
4 changes: 2 additions & 2 deletions examples/lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ places.search({keyword: 'Vermonster'}, function(err, response) {
if(err) { console.log(err); return; }
console.log("search: ", response.results);

places.details({reference: response.results[0].reference}, function(err, response) {
places.details({placeid: response.results[0].place_id}, function(err, response) {
if(err) { console.log(err); return; }
console.log("search details: ", response.result.website);
});
Expand All @@ -25,6 +25,6 @@ places.autocomplete({input: 'Verm', types: "(cities)"}, function(err, response)
};

for(var index in response.predictions) {
places.details({reference: response.predictions[index].reference}, success);
places.details({placeid: response.predictions[index].place_id}, success);
}
});
5 changes: 1 addition & 4 deletions lib/google-places.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ GooglePlaces.prototype.search = function(options, cb) {
options = _.defaults(options, {
location: [42.3577990, -71.0536364],
radius: 10,
sensor: false,
language: 'en',
rankby: 'prominence',
types: []
Expand All @@ -53,7 +52,6 @@ GooglePlaces.prototype.search = function(options, cb) {
GooglePlaces.prototype.autocomplete = function(options, cb) {
options = _.defaults(options, {
language: "en",
sensor: false
});

this._doRequest(this._generateUrl(options, 'autocomplete'), cb);
Expand All @@ -62,8 +60,7 @@ GooglePlaces.prototype.autocomplete = function(options, cb) {
// Goolge place details
GooglePlaces.prototype.details = function(options, cb) {
options = _.defaults(options, {
reference: options.reference,
sensor: false,
placeid: options.placeid,
language: 'en'
});

Expand Down
8 changes: 4 additions & 4 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ fakeweb.allowNetConnect = false;

// fake the search
fakeweb.registerUri({
uri: 'https://maps.googleapis.com/maps/api/place/search/json?location=42.357799%2C-71.0536364&radius=10&sensor=false&language=en&rankby=prominence&key=fake_key',
uri: 'https://maps.googleapis.com/maps/api/place/search/json?location=42.357799%2C-71.0536364&radius=10&language=en&rankby=prominence&key=fake_key',
body: '{"results" : [{"name": "Vermonster", "id":"1"}], "status" : "OK"}'
});
// fake the autocomplete
fakeweb.registerUri({
uri: 'https://maps.googleapis.com/maps/api/place/autocomplete/json?language=en&sensor=false&key=fake_key',
uri: 'https://maps.googleapis.com/maps/api/place/autocomplete/json?language=en&key=fake_key',
body: '{"predictions" : [{"description": "Vermonster", "id":"1"}, {"description": "Vermont", "id":"2"}, {"description": "Vermilion", "id": "3"}], "status" : "OK"}'
});
//fake the details
fakeweb.registerUri({
uri: 'https://maps.googleapis.com/maps/api/place/details/json?reference=ABC123&sensor=false&language=en&key=fake_key',
uri: 'https://maps.googleapis.com/maps/api/place/details/json?placeid=ABC123&language=en&key=fake_key',
body: '{"result" : {"rating": 2.5}, "status" : "OK"}'
});

Expand Down Expand Up @@ -83,7 +83,7 @@ vows.describe('Places autocomplete').addBatch({
vows.describe('Place details').addBatch({
'new search': {
topic: function() {
new GooglePlaces('fake_key').details({reference: 'ABC123'}, this.callback);
new GooglePlaces('fake_key').details({placeid: 'ABC123'}, this.callback);
},
'should get details': function(err, response){
assert.equal(response.result.rating, 2.5);
Expand Down