I am trying to make an Android activity (in Java) using Mapbox. My search results using the Mapbox Places plugin currently show autocomplete suggestions internationally and I don't know how to limit these results to the user's proximity (ex: 50 miles).
My current implementation is essentially all the code Mapbox provides for this example: https://docs.mapbox.com/android/plugins/examples/global-location-search/
I want to do what they are showing here, however this example is in JavaScript: https://docs.mapbox.com/help/tutorials/local-search-geocoding-api/#optional-parameters
How can I accomplish this?
Thanks!
This depends on how you want to implement search for your Java/Android project. Your options are best outlined at https://docs.mapbox.com/android/plugins/overview/places/#search-options.
https://docs.mapbox.com/android/plugins/examples/global-location-search/ is an example which uses the Mapbox Places Plugin for Android.
The Plugin's PlaceOptions
class features a builder method to pass a proximity Point
.
If you don't want to use the Plugin, the MapboxGeocoding
class (via the .builder()
has a proximity method as well. Here's a Mapbox demo app example that uses the MapboxGeocoding
wrapper.