title: React-Google-Maps API: How to search current location for a search result?
body: <p>I'm trying to build a similar map as on Airbnb, where you can view place markers as you drag the map around. I would like to search for &quot;treatment centers&quot; and place markers using the Google Places API on a map.</p>
  <p>I have been using the new, re-written @react-google-maps/api. So far, I was able to create both a search box and an autocomplete and get their latitude and longitude, but both offer only specific locations rather than the most similar searches (ex. if you search Taco Bell on Google Maps, it shows up with several options near you). The code below displays a map with the search box:</p>
  <pre><code>import { GoogleMap, LoadScript, Marker, StandaloneSearchBox, Autocomplete } from '@react-google-maps/api';
  
  class HeaderMap extends Component {
    constructor (props) {
      super(props)
  
      this.autocomplete = null
  
      this.onLoad = this.onLoad.bind(this)
      this.onPlaceChanged = this.onPlaceChanged.bind(this)
  
      this.state = {
        currentLocation: {lat: 0, lng: 0},
        markers: [],
        zoom: 8
      }
    }
    
  
    componentDidMount() {
      navigator?.geolocation.getCurrentPosition(({coords: {latitude: lat, longitude: lng}}) =&gt; {
        const pos = {lat, lng}
        this.setState({currentLocation: pos})  
      })
    }
  
    onLoad (autocomplete) {
      console.log('autocomplete: ', autocomplete)
  
      this.autocomplete = autocomplete
    }
  
  
    onPlaceChanged() {
      if (this.autocomplete !== null) {
        let lat = this.autocomplete.getPlace().geometry.location.lat()
        let long = this.autocomplete.getPlace().geometry.location.lat()
      } else {
        console.log('Autocomplete is not loaded yet!')
      }
    }
  
    render() {
      return (
        &lt;LoadScript
          googleMapsApiKey=&quot;API_KEY_HERE&quot;
          libraries={[&quot;places&quot;]}
        &gt;
          &lt;GoogleMap
            id='search-box-example'
            mapContainerStyle={containerStyle}
            center={this.state.currentLocation}
            zoom={14}
            // onDragEnd={search for centers in current location}
          &gt;
            &lt;Marker key={1} position={this.state.currentLocation} /&gt;
            &lt;Autocomplete
              onLoad={this.onLoad}
              onPlaceChanged={this.onPlaceChanged}
            &gt;
              &lt;input
                type=&quot;text&quot;
                placeholder=&quot;Customized your placeholder&quot;
                style={inputStyles}
              /&gt;
            &lt;/Autocomplete&gt;
          &lt;/GoogleMap&gt;
        &lt;/LoadScript&gt;
      );
    }
  }
  </code></pre>
  <p>How can I automatically search the bounds of the location and get the latitude and longitude of each result based on keywords? Thanks for your help!</p>