From db40a42bbb0271d37db4b6963f84aa7a62014f73 Mon Sep 17 00:00:00 2001 From: Jake McGuire Date: Thu, 4 Sep 2014 13:22:04 -0700 Subject: [PATCH 1/4] Remove sensor parameter Closes #12. This parameter is no longer required for [Search](https://developers.google.com/places/documentation/search), [Autocomplete](https://developers.google.com/places/documentation/autocomplete), or [Detail](https://developers.google.com/places/documentation/detail) --- lib/google-places.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/google-places.js b/lib/google-places.js index 2c4a5e7..bf369df 100644 --- a/lib/google-places.js +++ b/lib/google-places.js @@ -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: [] @@ -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); @@ -63,7 +61,6 @@ GooglePlaces.prototype.autocomplete = function(options, cb) { GooglePlaces.prototype.details = function(options, cb) { options = _.defaults(options, { reference: options.reference, - sensor: false, language: 'en' }); From 949d7319929d22e44ba0ae9a3bd655e7836ee14d Mon Sep 17 00:00:00 2001 From: Jake McGuire Date: Thu, 4 Sep 2014 15:29:53 -0700 Subject: [PATCH 2/4] Remove sensor from test URLs --- test/index.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/index.test.js b/test/index.test.js index f7637e0..4e6b207 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -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?reference=ABC123&language=en&key=fake_key', body: '{"result" : {"rating": 2.5}, "status" : "OK"}' }); From ae2cb339c854ef38a9fe79d5d6d9f2c1ea9f3d46 Mon Sep 17 00:00:00 2001 From: Jake McGuire Date: Thu, 4 Sep 2014 16:13:52 -0700 Subject: [PATCH 3/4] Replace reference with place_id or placeid Closes #11. The Places API deprecated the _reference_ parameter on June 24, 2014 and it will no longer be accepted starting June 24, 2015. Requests should instead use the _place_id_ returned by a Search request, which can be passed to a follow-up Detail request with the _placeid_ parameter. (Please note the lack of underscore in the parameter for the Detail request.) [Source](https://developers.google.com/places/documentation/search) --- README.md | 4 ++-- lib/google-places.js | 2 +- test/index.test.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8ff0e77..7b813ea 100644 --- a/README.md +++ b/README.md @@ -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/ }); @@ -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); } }); ``` diff --git a/lib/google-places.js b/lib/google-places.js index bf369df..3ed3510 100644 --- a/lib/google-places.js +++ b/lib/google-places.js @@ -60,7 +60,7 @@ GooglePlaces.prototype.autocomplete = function(options, cb) { // Goolge place details GooglePlaces.prototype.details = function(options, cb) { options = _.defaults(options, { - reference: options.reference, + placeid: options.placeid, language: 'en' }); diff --git a/test/index.test.js b/test/index.test.js index 4e6b207..a995837 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -17,7 +17,7 @@ fakeweb.registerUri({ }); //fake the details fakeweb.registerUri({ - uri: 'https://maps.googleapis.com/maps/api/place/details/json?reference=ABC123&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"}' }); @@ -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); From f1af878dceaa3ba1c2090401fea2f252c1f89050 Mon Sep 17 00:00:00 2001 From: Jake McGuire Date: Fri, 5 Sep 2014 12:01:15 -0700 Subject: [PATCH 4/4] Update lookup example --- examples/lookup.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/lookup.js b/examples/lookup.js index bc59b1f..5d19250 100644 --- a/examples/lookup.js +++ b/examples/lookup.js @@ -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); }); @@ -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); } });