|
743 | 743 |
|
744 | 744 | L.Control.Geocoder.Google = L.Class.extend({
|
745 | 745 | 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: {} |
747 | 749 | },
|
748 | 750 |
|
749 | 751 | initialize: function(key, options) {
|
750 |
| - this._key = key; |
751 |
| - this._options = options; |
| 752 | + this._key = key; |
| 753 | + L.setOptions(this, options); |
752 | 754 | },
|
753 | 755 |
|
754 | 756 | geocode: function(query, cb, context) {
|
|
759 | 761 | {
|
760 | 762 | params['key'] = this._key
|
761 | 763 | }
|
762 |
| - params = L.Util.extend(params, this._options); |
| 764 | + params = L.Util.extend(params, this.options.geocodingQueryParams); |
763 | 765 |
|
764 | 766 | L.Control.Geocoder.getJSON(this.options.service_url, params, function(data) {
|
765 | 767 | var results = [],
|
|
775 | 777 | name: loc.formatted_address,
|
776 | 778 | bbox: latLngBounds,
|
777 | 779 | center: latLng,
|
778 |
| - address_components: loc.address_components |
| 780 | + properties: loc.address_components |
779 | 781 | };
|
780 | 782 | }
|
781 | 783 | }
|
|
788 | 790 | var params = {
|
789 | 791 | latlng: encodeURIComponent(location.lat) + ',' + encodeURIComponent(location.lng)
|
790 | 792 | };
|
| 793 | + params = L.Util.extend(params, this.options.reverseQueryParams); |
791 | 794 | if(this._key && this._key.length)
|
792 | 795 | {
|
793 | 796 | params['key'] = this._key
|
|
805 | 808 | results[i] = {
|
806 | 809 | name: loc.formatted_address,
|
807 | 810 | bbox: latLngBounds,
|
808 |
| - center: latLng |
| 811 | + center: latLng, |
| 812 | + properties: loc.address_components |
809 | 813 | };
|
810 | 814 | }
|
811 | 815 | }
|
|
815 | 819 | }
|
816 | 820 | });
|
817 | 821 |
|
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); |
820 | 824 | };
|
821 | 825 |
|
822 | 826 | L.Control.Geocoder.Photon = L.Class.extend({
|
|
0 commit comments