Reputation: 8963
I have an area (multiple regions in France) on the map described by geographical coordinates (longitude and latitudes). Is there a way to pass this set of coordinates to google API and limit search results within this area?
We are using the following example from google documentation:
https://developers.google.com/maps/documentation/javascript/examples/places-searchbox
Thank you
Upvotes: 1
Views: 3416
Reputation: 161324
You can use the bounds
SearchBoxOption to "bias" the search towards your geographic area.
google.maps.places.SearchBoxOptions object specification
The options that can be set on a SearchBox object.
Properties
Properties Type Description
bounds LatLngBounds The area towards which to bias query predictions. Predictions are biased towards, but not restricted to, queries targeting these bounds.
Note that a LatLngBounds
object is a rectangle, not a polygon.
Upvotes: 1
Reputation: 7416
You can't pass a special set of coordinates to your Searchbox
, nor to the Autocompelte
field.
However, you can limit your result to a type of area. All types are defined in the documentation. Depending of what you call "regions", you should take a look to restrict your search to
types: ['(regions)']
or types: ['(administrative_area_level_{X})']
Upvotes: 0