How to stop autompletesearch in GooglePlacesAutocomplete when a location is already selected?
I am using react-native-google-places-autocomplete. When the user types a location, the search options appear and the user is then able to select a location.
However, the search options still appear after the user has pressed and selected a location.
How to make sure the search options disappear after the user has selected a location.
Below is my component:
<GooglePlacesAutocomplete
placeholder='Business Location'
minLength={2} // minimum length of text to search
autoFocus={false}
returnKeyType={'search'} // Can be left out for default return key https://facebook.github.io/react-native/docs/textinput.html#returnkeytype
listViewDisplayed='auto' // true/false/undefined
fetchDetails={true}
renderDescription={row => row.description} // custom description render
onPress={(data, details = null) => { // 'details' is provided when fetchDetails = true
this.setState({ location: data.description });
this.validateLocation();
}}
getDefaultValue={() => ''}
query={{
// available options: https://developers.google.com/places/web-service/autocomplete
key: 'XXXXXXXXXXXXXXXXXXXXXXXX',
language: 'en', // language of the results
types: 'geocode' // default: 'geocode'
}}
styles={{
textInputContainer: {
backgroundColor: 'white',
width: 0.8*width,
marginLeft: 0.1*width,
height: 0.1*height,
zIndex: 1,
borderTopWidth: 0,
borderBottomWidth: 1,
borderColor: 'black'
}
}}
//currentLocation={true} // Will add a 'Current location' button at the top of the predefined places list
nearbyPlacesAPI='GooglePlacesSearch' // Which API to use: GoogleReverseGeocoding or GooglePlacesSearch
GoogleReverseGeocodingQuery={{
// available options for GoogleReverseGeocoding API : https://developers.google.com/maps/documentation/geocoding/intro
}}
GooglePlacesSearchQuery={{
// available options for GooglePlacesSearch API : https://developers.google.com/places/web-service/search
rankby: 'distance',
types: ''
}}
filterReverseGeocodingByTypes={['locality', 'administrative_area_level_3']} // filter the reverse geocoding results by types - ['locality', 'administrative_area_level_3'] if you want to display only cities
predefinedPlaces={[//homePlace, workPlace
]}
debounce={200} // debounce the requests in ms. Set to 0 to remove debounce. By default 0ms.
value={this.state.location}
onChangeText={(location) => {
this.setState({ location });
this.validateLocation();
}}
//renderLeftButton={() => <Icon name="map-marker" size={28} color="#000" style={{ marginTop: 0.015*width }} />}
//renderRightButton={() => <Icon name="rocket" size={30} color="#900" />}
/>
react-native googleplacesautocomplete
add a comment |
I am using react-native-google-places-autocomplete. When the user types a location, the search options appear and the user is then able to select a location.
However, the search options still appear after the user has pressed and selected a location.
How to make sure the search options disappear after the user has selected a location.
Below is my component:
<GooglePlacesAutocomplete
placeholder='Business Location'
minLength={2} // minimum length of text to search
autoFocus={false}
returnKeyType={'search'} // Can be left out for default return key https://facebook.github.io/react-native/docs/textinput.html#returnkeytype
listViewDisplayed='auto' // true/false/undefined
fetchDetails={true}
renderDescription={row => row.description} // custom description render
onPress={(data, details = null) => { // 'details' is provided when fetchDetails = true
this.setState({ location: data.description });
this.validateLocation();
}}
getDefaultValue={() => ''}
query={{
// available options: https://developers.google.com/places/web-service/autocomplete
key: 'XXXXXXXXXXXXXXXXXXXXXXXX',
language: 'en', // language of the results
types: 'geocode' // default: 'geocode'
}}
styles={{
textInputContainer: {
backgroundColor: 'white',
width: 0.8*width,
marginLeft: 0.1*width,
height: 0.1*height,
zIndex: 1,
borderTopWidth: 0,
borderBottomWidth: 1,
borderColor: 'black'
}
}}
//currentLocation={true} // Will add a 'Current location' button at the top of the predefined places list
nearbyPlacesAPI='GooglePlacesSearch' // Which API to use: GoogleReverseGeocoding or GooglePlacesSearch
GoogleReverseGeocodingQuery={{
// available options for GoogleReverseGeocoding API : https://developers.google.com/maps/documentation/geocoding/intro
}}
GooglePlacesSearchQuery={{
// available options for GooglePlacesSearch API : https://developers.google.com/places/web-service/search
rankby: 'distance',
types: ''
}}
filterReverseGeocodingByTypes={['locality', 'administrative_area_level_3']} // filter the reverse geocoding results by types - ['locality', 'administrative_area_level_3'] if you want to display only cities
predefinedPlaces={[//homePlace, workPlace
]}
debounce={200} // debounce the requests in ms. Set to 0 to remove debounce. By default 0ms.
value={this.state.location}
onChangeText={(location) => {
this.setState({ location });
this.validateLocation();
}}
//renderLeftButton={() => <Icon name="map-marker" size={28} color="#000" style={{ marginTop: 0.015*width }} />}
//renderRightButton={() => <Icon name="rocket" size={30} color="#900" />}
/>
react-native googleplacesautocomplete
add a comment |
I am using react-native-google-places-autocomplete. When the user types a location, the search options appear and the user is then able to select a location.
However, the search options still appear after the user has pressed and selected a location.
How to make sure the search options disappear after the user has selected a location.
Below is my component:
<GooglePlacesAutocomplete
placeholder='Business Location'
minLength={2} // minimum length of text to search
autoFocus={false}
returnKeyType={'search'} // Can be left out for default return key https://facebook.github.io/react-native/docs/textinput.html#returnkeytype
listViewDisplayed='auto' // true/false/undefined
fetchDetails={true}
renderDescription={row => row.description} // custom description render
onPress={(data, details = null) => { // 'details' is provided when fetchDetails = true
this.setState({ location: data.description });
this.validateLocation();
}}
getDefaultValue={() => ''}
query={{
// available options: https://developers.google.com/places/web-service/autocomplete
key: 'XXXXXXXXXXXXXXXXXXXXXXXX',
language: 'en', // language of the results
types: 'geocode' // default: 'geocode'
}}
styles={{
textInputContainer: {
backgroundColor: 'white',
width: 0.8*width,
marginLeft: 0.1*width,
height: 0.1*height,
zIndex: 1,
borderTopWidth: 0,
borderBottomWidth: 1,
borderColor: 'black'
}
}}
//currentLocation={true} // Will add a 'Current location' button at the top of the predefined places list
nearbyPlacesAPI='GooglePlacesSearch' // Which API to use: GoogleReverseGeocoding or GooglePlacesSearch
GoogleReverseGeocodingQuery={{
// available options for GoogleReverseGeocoding API : https://developers.google.com/maps/documentation/geocoding/intro
}}
GooglePlacesSearchQuery={{
// available options for GooglePlacesSearch API : https://developers.google.com/places/web-service/search
rankby: 'distance',
types: ''
}}
filterReverseGeocodingByTypes={['locality', 'administrative_area_level_3']} // filter the reverse geocoding results by types - ['locality', 'administrative_area_level_3'] if you want to display only cities
predefinedPlaces={[//homePlace, workPlace
]}
debounce={200} // debounce the requests in ms. Set to 0 to remove debounce. By default 0ms.
value={this.state.location}
onChangeText={(location) => {
this.setState({ location });
this.validateLocation();
}}
//renderLeftButton={() => <Icon name="map-marker" size={28} color="#000" style={{ marginTop: 0.015*width }} />}
//renderRightButton={() => <Icon name="rocket" size={30} color="#900" />}
/>
react-native googleplacesautocomplete
I am using react-native-google-places-autocomplete. When the user types a location, the search options appear and the user is then able to select a location.
However, the search options still appear after the user has pressed and selected a location.
How to make sure the search options disappear after the user has selected a location.
Below is my component:
<GooglePlacesAutocomplete
placeholder='Business Location'
minLength={2} // minimum length of text to search
autoFocus={false}
returnKeyType={'search'} // Can be left out for default return key https://facebook.github.io/react-native/docs/textinput.html#returnkeytype
listViewDisplayed='auto' // true/false/undefined
fetchDetails={true}
renderDescription={row => row.description} // custom description render
onPress={(data, details = null) => { // 'details' is provided when fetchDetails = true
this.setState({ location: data.description });
this.validateLocation();
}}
getDefaultValue={() => ''}
query={{
// available options: https://developers.google.com/places/web-service/autocomplete
key: 'XXXXXXXXXXXXXXXXXXXXXXXX',
language: 'en', // language of the results
types: 'geocode' // default: 'geocode'
}}
styles={{
textInputContainer: {
backgroundColor: 'white',
width: 0.8*width,
marginLeft: 0.1*width,
height: 0.1*height,
zIndex: 1,
borderTopWidth: 0,
borderBottomWidth: 1,
borderColor: 'black'
}
}}
//currentLocation={true} // Will add a 'Current location' button at the top of the predefined places list
nearbyPlacesAPI='GooglePlacesSearch' // Which API to use: GoogleReverseGeocoding or GooglePlacesSearch
GoogleReverseGeocodingQuery={{
// available options for GoogleReverseGeocoding API : https://developers.google.com/maps/documentation/geocoding/intro
}}
GooglePlacesSearchQuery={{
// available options for GooglePlacesSearch API : https://developers.google.com/places/web-service/search
rankby: 'distance',
types: ''
}}
filterReverseGeocodingByTypes={['locality', 'administrative_area_level_3']} // filter the reverse geocoding results by types - ['locality', 'administrative_area_level_3'] if you want to display only cities
predefinedPlaces={[//homePlace, workPlace
]}
debounce={200} // debounce the requests in ms. Set to 0 to remove debounce. By default 0ms.
value={this.state.location}
onChangeText={(location) => {
this.setState({ location });
this.validateLocation();
}}
//renderLeftButton={() => <Icon name="map-marker" size={28} color="#000" style={{ marginTop: 0.015*width }} />}
//renderRightButton={() => <Icon name="rocket" size={30} color="#900" />}
/>
react-native googleplacesautocomplete
react-native googleplacesautocomplete
asked Nov 20 at 20:11
codigomonstruo
572723
572723
add a comment |
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400805%2fhow-to-stop-autompletesearch-in-googleplacesautocomplete-when-a-location-is-alre%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400805%2fhow-to-stop-autompletesearch-in-googleplacesautocomplete-when-a-location-is-alre%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown