How to stop autompletesearch in GooglePlacesAutocomplete when a location is already selected?












1














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" />}
/>









share|improve this question



























    1














    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" />}
    />









    share|improve this question

























      1












      1








      1


      1





      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" />}
      />









      share|improve this question













      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 20 at 20:11









      codigomonstruo

      572723




      572723





























          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
          });


          }
          });














          draft saved

          draft discarded


















          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
















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          TypeError: fit_transform() missing 1 required positional argument: 'X'