StandaloneSearchBox

The StandaloneSearchBox component wraps google.maps.places.SearchBox for free-form place search outside a map control.

Storybook

Open the StandaloneSearchBox story

Props

PropTypeDescription
boundsgoogle.maps.LatLngBounds | google.maps.LatLngBoundsLiteralBiases results to a bounds area.
optionsgoogle.maps.places.SearchBoxOptionsInitial SearchBox options.
valuestringInput value when using the built-in input.
placeholderstringInput placeholder when using the built-in input.
inputIdstringBuilt-in input id.
inputClassstringBuilt-in input class.
inputStylestringBuilt-in input inline style.
disabledbooleanDisables the built-in input.
onPlacesChanged(places) => voidCalled when selected places change.
onLoad(searchBox) => voidCalled after creation.
onUnmount(searchBox) => voidCalled before teardown.

Events

The component also dispatches places_changed with the selected places.

Usage

<APIProvider apiKey="YOUR_API_KEY" libraries={['places']}>
  <StandaloneSearchBox
    placeholder="Search places"
    onPlacesChanged={(places) => console.log(places)}
  />
</APIProvider>
svelte