I want to custom searchbox autocomplete on Google Maps. How to make searchbox outside on google maps?
Google doesn't support this.
Please refer to Getting Help section in the README.
You can put an input anywhere by doing like this :
<input
ref={(c) => {
if (!c) {
return;
}
const searchBox = new google.maps.places.SearchBox(c, { types: ['geocode'] });
searchBox.addListener('places_changed', ()=> {
const places = searchBox.getPlaces();
if (places.length > 0) {
const position = places[0].geometry.location;
...
}
})
}}
placeholder="Search a place..."
type="text"
style={styles.input}
/>
Most helpful comment
You can put an input anywhere by doing like this :