Skip to content

Commit ce82425

Browse files
committed
Update Google options handling and result parameter passing to be more in line with Nominatim's
1 parent 4c200fb commit ce82425

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

Control.Geocoder.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -743,12 +743,14 @@
743743

744744
L.Control.Geocoder.Google = L.Class.extend({
745745
options: {
746-
service_url: 'https://maps.googleapis.com/maps/api/geocode/json'
746+
service_url: 'https://maps.googleapis.com/maps/api/geocode/json',
747+
geocodingQueryParams: {},
748+
reverseQueryParams: {}
747749
},
748750

749751
initialize: function(key, options) {
750-
this._key = key;
751-
this._options = options;
752+
this._key = key;
753+
L.setOptions(this, options);
752754
},
753755

754756
geocode: function(query, cb, context) {
@@ -759,7 +761,7 @@
759761
{
760762
params['key'] = this._key
761763
}
762-
params = L.Util.extend(params, this._options);
764+
params = L.Util.extend(params, this.options.geocodingQueryParams);
763765

764766
L.Control.Geocoder.getJSON(this.options.service_url, params, function(data) {
765767
var results = [],
@@ -775,7 +777,7 @@
775777
name: loc.formatted_address,
776778
bbox: latLngBounds,
777779
center: latLng,
778-
address_components: loc.address_components
780+
properties: loc.address_components
779781
};
780782
}
781783
}
@@ -788,6 +790,7 @@
788790
var params = {
789791
latlng: encodeURIComponent(location.lat) + ',' + encodeURIComponent(location.lng)
790792
};
793+
params = L.Util.extend(params, this.options.reverseQueryParams);
791794
if(this._key && this._key.length)
792795
{
793796
params['key'] = this._key
@@ -805,7 +808,8 @@
805808
results[i] = {
806809
name: loc.formatted_address,
807810
bbox: latLngBounds,
808-
center: latLng
811+
center: latLng,
812+
properties: loc.address_components
809813
};
810814
}
811815
}
@@ -815,8 +819,8 @@
815819
}
816820
});
817821

818-
L.Control.Geocoder.google = function(key) {
819-
return new L.Control.Geocoder.Google(key);
822+
L.Control.Geocoder.google = function(key, options) {
823+
return new L.Control.Geocoder.Google(key, options);
820824
};
821825

822826
L.Control.Geocoder.Photon = L.Class.extend({

0 commit comments

Comments
 (0)