Skip to content

Commit

Permalink
Merge pull request #206 from yktv4/optional-params-support-google-rev…
Browse files Browse the repository at this point in the history
…erse-geocoding

Optional params support google reverse geocoding
  • Loading branch information
nchaulet authored Jan 24, 2017
2 parents 5484a64 + 8b7c7cf commit f476184
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
8 changes: 6 additions & 2 deletions lib/geocoder/googlegeocoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,12 @@ GoogleGeocoder.prototype._reverse = function (query, callback) {
params.language = query.language;
}

if (query.region) {
params.region = query.region;
if (query.result_type) {
params.result_type = query.result_type;
}

if (query.location_type) {
params.location_type = query.location_type;
}

this._signedRequest(this._endpoint, params);
Expand Down
17 changes: 12 additions & 5 deletions test/geocoder/googlegeocoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,18 +571,25 @@ describe('GoogleGeocoder', function() {
});
});

it('Should accept `language` and `region` as options', function() {
it('Should accept `language`, `result_type` and `location_type` as options', function() {
var mock = sinon.mock(mockedHttpAdapter);
mock.expects('get').withArgs('https://maps.googleapis.com/maps/api/geocode/json', {
latlng: "40.714232,-73.9612889",
language: "ru-RU",
region: ".de",
sensor: false
sensor: false,
result_type: 'country',
location_type: 'ROOFTOP',
}).once().returns({then: function() {}});

var googleAdapter = new GoogleGeocoder(mockedHttpAdapter, { language: 'fr', region: '.ru' });
var googleAdapter = new GoogleGeocoder(mockedHttpAdapter);

googleAdapter.reverse({ lat:40.714232, lon:-73.9612889, language: 'ru-RU', region: '.de' });
googleAdapter.reverse({
lat: 40.714232,
lon: -73.9612889,
language: 'ru-RU',
result_type: 'country',
location_type: 'ROOFTOP',
});

mock.verify();
});
Expand Down

0 comments on commit f476184

Please sign in to comment.