Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mapbox GeoCoder --> How to get nearby restaurants, hotels, shopping malls etc

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.

like image 906
Raju Avatar asked Dec 29 '25 14:12

Raju


1 Answers

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 ⚠️

like image 79
riastrad Avatar answered Jan 01 '26 11:01

riastrad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!