react-geosuggest
Advanced tools
Comparing version 1.11.1 to 1.12.0
@@ -0,1 +1,11 @@ | ||
## 1.12.0 (2015-10-22) | ||
#### Bug Fixes | ||
* doc comments, backward compatible changes ([96cca392](https://github.com/ubilabs/react-geosuggest/commit/96cca392f5b569247523cf784d34f1e1eb8b89d8)) | ||
* add copy css in build module ([bb988a1c](https://github.com/ubilabs/react-geosuggest/commit/bb988a1c5bf3079b170cd24c79bbd21093f49f93)) | ||
* googleMaps object moved out of props and set in componentDidMount ([955812df](https://github.com/ubilabs/react-geosuggest/commit/955812dfb702e8ea6318d89b2ef36d866c5c4354)) | ||
### 1.11.1 (2015-10-12) | ||
@@ -2,0 +12,0 @@ |
@@ -36,3 +36,3 @@ /* global google */ | ||
types: null, | ||
googleMaps: google && google.maps, | ||
googleMaps: null, | ||
onSuggestSelect: function onSuggestSelect() {}, | ||
@@ -59,5 +59,3 @@ onFocus: function onFocus() {}, | ||
activeSuggest: null, | ||
suggests: [], | ||
geocoder: new this.props.googleMaps.Geocoder(), | ||
autocompleteService: new this.props.googleMaps.places.AutocompleteService() | ||
suggests: [] | ||
}; | ||
@@ -77,2 +75,32 @@ }, | ||
/** | ||
* Called on the client side after component is mounted. | ||
* Google api sdk object will be obtained and cached as a instance property. | ||
* Necessary objects of google api will also be determined and saved. | ||
*/ | ||
componentDidMount: function componentDidMount() { | ||
this.setInputValue(this.props.initialValue); | ||
var googleMaps = this.props.googleMaps || google && google.maps || this.googleMaps; | ||
if (!googleMaps) { | ||
console.error('Google map api was not found in the page.'); | ||
} else { | ||
this.googleMaps = googleMaps; | ||
} | ||
this.autocompleteService = new googleMaps.places.AutocompleteService(); | ||
this.geocoder = new googleMaps.Geocoder(); | ||
}, | ||
/** | ||
* Method used for setting initial value. | ||
* @param {string} value to set in input | ||
*/ | ||
setInputValue: function setInputValue(value) { | ||
this.setState({ | ||
userInput: value | ||
}); | ||
}, | ||
/** | ||
* When the input got changed | ||
@@ -126,3 +154,3 @@ */ | ||
input: this.state.userInput, | ||
location: this.props.location || new this.props.googleMaps.LatLng(0, 0), | ||
location: this.props.location || new this.googleMaps.LatLng(0, 0), | ||
radius: this.props.radius | ||
@@ -145,3 +173,3 @@ }; | ||
this.state.autocompleteService.getPlacePredictions(options, (function (suggestsGoogle) { | ||
this.autocompleteService.getPlacePredictions(options, (function (suggestsGoogle) { | ||
this.updateSuggests(suggestsGoogle); | ||
@@ -303,4 +331,4 @@ | ||
geocodeSuggest: function geocodeSuggest(suggest) { | ||
this.state.geocoder.geocode({ address: suggest.label }, (function (results, status) { | ||
if (status !== this.props.googleMaps.GeocoderStatus.OK) { | ||
this.geocoder.geocode({ address: suggest.label }, (function (results, status) { | ||
if (status !== this.googleMaps.GeocoderStatus.OK) { | ||
return; | ||
@@ -307,0 +335,0 @@ } |
{ | ||
"name": "react-geosuggest", | ||
"version": "1.11.1", | ||
"version": "1.12.0", | ||
"description": "A React autosuggest for the Google Maps Places API.", | ||
@@ -45,3 +45,3 @@ "main": "module/Geosuggest.js", | ||
"js:browser:uglify": "uglifyjs dist/react-geosuggest.js -o dist/react-geosuggest.min.js -c warnings=false,drop_console=true --mangle", | ||
"build:module": "babel src --out-dir module", | ||
"build:module": "babel src --out-dir module && cp src/geosuggest.css module/", | ||
"build:browser": "npm run js:browser && npm run js:browser:uglify", | ||
@@ -48,0 +48,0 @@ "build:example": "npm run prepare:example && npm run js:example:uglify", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35067
8
466