From 689dfd92d3a12a2e2bc8fb5807a0b985d45924c4 Mon Sep 17 00:00:00 2001 From: Xavi Bonell Date: Wed, 26 Feb 2020 11:51:07 +0100 Subject: [PATCH 1/3] fix(index): updating Google key for the example environment --- example/src/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/src/index.html b/example/src/index.html index 554ee4c0..f1111eb1 100644 --- a/example/src/index.html +++ b/example/src/index.html @@ -3,7 +3,7 @@ React Geosuggest - +
From 7e3f71412e442b5073058f8bebd11cbaa2f5554a Mon Sep 17 00:00:00 2001 From: Xavi Bonell Date: Wed, 26 Feb 2020 11:52:17 +0100 Subject: [PATCH 2/3] fix(geosuggest): changing default API call to the geocoder interface --- src/Geosuggest.tsx | 82 ++++++++++++++-------------------------------- 1 file changed, 24 insertions(+), 58 deletions(-) diff --git a/src/Geosuggest.tsx b/src/Geosuggest.tsx index ef469e47..003ac8ac 100644 --- a/src/Geosuggest.tsx +++ b/src/Geosuggest.tsx @@ -501,68 +501,34 @@ export default class extends React.Component { return; } - if ( - suggestToGeocode.placeId && - !suggestToGeocode.isFixture && - this.placesService - ) { - const options: any = { - placeId: suggestToGeocode.placeId, - sessionToken: this.sessionToken - }; - - if (this.props.placeDetailFields) { - options.fields = ['geometry', ...this.props.placeDetailFields]; - } - - this.placesService.getDetails(options, (results, status) => { - if (status === this.googleMaps.places.PlacesServiceStatus.OK) { - const gmaps = results; - const location = gmaps.geometry.location; - const suggest = { - ...suggestToGeocode, - gmaps, - location: { - lat: location.lat(), - lng: location.lng() - } - }; + const options: google.maps.GeocoderRequest = { + address: suggestToGeocode.label, + bounds: this.props.bounds, + componentRestrictions: this.props.country + ? {country: this.props.country} + : undefined, + location: this.props.location + }; - this.sessionToken = new google.maps.places.AutocompleteSessionToken(); - if (this.props.onSuggestSelect) { - this.props.onSuggestSelect(suggest); + this.geocoder.geocode(options, (results, status) => { + if (status === this.googleMaps.GeocoderStatus.OK) { + const gmaps = results[0]; + const location = gmaps.geometry.location; + const suggest = { + ...suggestToGeocode, + gmaps, + location: { + lat: location.lat(), + lng: location.lng() } - } - }); - } else { - const options: google.maps.GeocoderRequest = { - address: suggestToGeocode.label, - bounds: this.props.bounds, - componentRestrictions: this.props.country - ? {country: this.props.country} - : undefined, - location: this.props.location - }; - - this.geocoder.geocode(options, (results, status) => { - if (status === this.googleMaps.GeocoderStatus.OK) { - const gmaps = results[0]; - const location = gmaps.geometry.location; - const suggest = { - ...suggestToGeocode, - gmaps, - location: { - lat: location.lat(), - lng: location.lng() - } - }; + }; - if (this.props.onSuggestSelect) { - this.props.onSuggestSelect(suggest); - } + if (this.props.onSuggestSelect) { + this.props.onSuggestSelect(suggest); } - }); - } + } + }); + } /** From 6f15c2f4c0763bf3d0cf78c4d39d4742d7346c60 Mon Sep 17 00:00:00 2001 From: Xavi Bonell Date: Wed, 26 Feb 2020 16:17:30 +0100 Subject: [PATCH 3/3] refactor(geosuggest): generating module files --- module/Geosuggest.esm.js | 67 ++++++++++++---------------------------- module/Geosuggest.umd.js | 67 ++++++++++++---------------------------- 2 files changed, 40 insertions(+), 94 deletions(-) diff --git a/module/Geosuggest.esm.js b/module/Geosuggest.esm.js index d931fec5..fa5e06c3 100644 --- a/module/Geosuggest.esm.js +++ b/module/Geosuggest.esm.js @@ -1481,54 +1481,27 @@ var default_1$3 = /** @class */ (function (_super) { if (!this.geocoder) { return; } - if (suggestToGeocode.placeId && - !suggestToGeocode.isFixture && - this.placesService) { - var options = { - placeId: suggestToGeocode.placeId, - sessionToken: this.sessionToken - }; - if (this.props.placeDetailFields) { - options.fields = ['geometry'].concat(this.props.placeDetailFields); - } - this.placesService.getDetails(options, function (results, status) { - if (status === _this.googleMaps.places.PlacesServiceStatus.OK) { - var gmaps = results; - var location_1 = gmaps.geometry.location; - var suggest = __assign({}, suggestToGeocode, { gmaps: gmaps, location: { - lat: location_1.lat(), - lng: location_1.lng() - } }); - _this.sessionToken = new google.maps.places.AutocompleteSessionToken(); - if (_this.props.onSuggestSelect) { - _this.props.onSuggestSelect(suggest); - } - } - }); - } - else { - var options = { - address: suggestToGeocode.label, - bounds: this.props.bounds, - componentRestrictions: this.props.country - ? { country: this.props.country } - : undefined, - location: this.props.location - }; - this.geocoder.geocode(options, function (results, status) { - if (status === _this.googleMaps.GeocoderStatus.OK) { - var gmaps = results[0]; - var location_2 = gmaps.geometry.location; - var suggest = __assign({}, suggestToGeocode, { gmaps: gmaps, location: { - lat: location_2.lat(), - lng: location_2.lng() - } }); - if (_this.props.onSuggestSelect) { - _this.props.onSuggestSelect(suggest); - } + var options = { + address: suggestToGeocode.label, + bounds: this.props.bounds, + componentRestrictions: this.props.country + ? { country: this.props.country } + : undefined, + location: this.props.location + }; + this.geocoder.geocode(options, function (results, status) { + if (status === _this.googleMaps.GeocoderStatus.OK) { + var gmaps = results[0]; + var location_1 = gmaps.geometry.location; + var suggest = __assign({}, suggestToGeocode, { gmaps: gmaps, location: { + lat: location_1.lat(), + lng: location_1.lng() + } }); + if (_this.props.onSuggestSelect) { + _this.props.onSuggestSelect(suggest); } - }); - } + } + }); }; /** * Render the view diff --git a/module/Geosuggest.umd.js b/module/Geosuggest.umd.js index 81c11d7d..28a617c9 100644 --- a/module/Geosuggest.umd.js +++ b/module/Geosuggest.umd.js @@ -1487,54 +1487,27 @@ if (!this.geocoder) { return; } - if (suggestToGeocode.placeId && - !suggestToGeocode.isFixture && - this.placesService) { - var options = { - placeId: suggestToGeocode.placeId, - sessionToken: this.sessionToken - }; - if (this.props.placeDetailFields) { - options.fields = ['geometry'].concat(this.props.placeDetailFields); - } - this.placesService.getDetails(options, function (results, status) { - if (status === _this.googleMaps.places.PlacesServiceStatus.OK) { - var gmaps = results; - var location_1 = gmaps.geometry.location; - var suggest = __assign({}, suggestToGeocode, { gmaps: gmaps, location: { - lat: location_1.lat(), - lng: location_1.lng() - } }); - _this.sessionToken = new google.maps.places.AutocompleteSessionToken(); - if (_this.props.onSuggestSelect) { - _this.props.onSuggestSelect(suggest); - } - } - }); - } - else { - var options = { - address: suggestToGeocode.label, - bounds: this.props.bounds, - componentRestrictions: this.props.country - ? { country: this.props.country } - : undefined, - location: this.props.location - }; - this.geocoder.geocode(options, function (results, status) { - if (status === _this.googleMaps.GeocoderStatus.OK) { - var gmaps = results[0]; - var location_2 = gmaps.geometry.location; - var suggest = __assign({}, suggestToGeocode, { gmaps: gmaps, location: { - lat: location_2.lat(), - lng: location_2.lng() - } }); - if (_this.props.onSuggestSelect) { - _this.props.onSuggestSelect(suggest); - } + var options = { + address: suggestToGeocode.label, + bounds: this.props.bounds, + componentRestrictions: this.props.country + ? { country: this.props.country } + : undefined, + location: this.props.location + }; + this.geocoder.geocode(options, function (results, status) { + if (status === _this.googleMaps.GeocoderStatus.OK) { + var gmaps = results[0]; + var location_1 = gmaps.geometry.location; + var suggest = __assign({}, suggestToGeocode, { gmaps: gmaps, location: { + lat: location_1.lat(), + lng: location_1.lng() + } }); + if (_this.props.onSuggestSelect) { + _this.props.onSuggestSelect(suggest); } - }); - } + } + }); }; /** * Render the view