3

I am using Mapbox Geocoder for searching places in our app. But, I also need to get all the nearby places like restaurants, hotels etc. Is it possible with Mapbox Geocoder?

This is the code we are using for forward geocode,

    let region = RectangularRegion(southWest:   CLLocationCoordinate2DMake(swlat, swlng), northEast: CLLocationCoordinate2DMake(nelat, nelng))

    let options = ForwardGeocodeOptions(query: input)
    options.allowedRegion = region --> To restrict search

I can do this with Google autocomplete,

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=1500&type=restaurant&keyword=cruise&key=API_KEY.

But, I can't use both Mapbox and Google.

Dekker1
  • 5,565
  • 25
  • 33
Raju
  • 250
  • 1
  • 2
  • 16

1 Answers1

5

The Geocoding API supports "category" search, although it's still marked as experimental. The documentation includes a list of the currently supported categories: https://docs.mapbox.com/api/search/#point-of-interest-category-coverage.

You can either build your own implementation to query the geocoding endpoint directly, or use the Open Source MapboxGeocoder.swift which acts as a native wrapper for the API.


⚠️ Disclaimer: I currently work at Mapbox ⚠️

riastrad
  • 1,624
  • 10
  • 22
  • It's still unclear to me how that category search works. I have tried adding category=park to the query parameters, but it won't change result... Perhaps adding an example to the documentation would help. – JB Theard Jan 15 '20 at 18:56