How to pass fuzzyMatch param to mapbox geocoding api

179 Views Asked by At

I am using MapboxAPI for geocoding but I am experiencing it is tending to approximate location to city center when it can not match exact location.

Per documentation there is fuzzyMatch(Boolean true:default) option that can change this behavior.

Since I am using MapboxAPI directly through URL I tried following but all of them are returning same result set.

/geocoding/v5/mapbox.places/[url_encoded_address_text].json?fuzzyMatch=true&access_token=pk.abc...
/geocoding/v5/mapbox.places/[url_encoded_address_text].json?fuzzyMatch=false&access_token=pk.abc...
/geocoding/v5/mapbox.places/[url_encoded_address_text].json?fuzzyMatch=1&access_token=pk.abc...
/geocoding/v5/mapbox.places/[url_encoded_address_text].json?fuzzyMatch=0&access_token=pk.abc...

Looks like fuzzyMatch option does not do anything.

Is there something I am doing wrong?

1

There are 1 best solutions below

0
Matt On

You are using it correctly with the true/false params (docs):

/geocoding/v5/mapbox.places/[url_encoded_address_text].json?fuzzyMatch=true&access_token=pk.abc...
/geocoding/v5/mapbox.places/[url_encoded_address_text].json?fuzzyMatch=false&access_token=pk.abc...

Using the example from the docs, a query using types=place of wahsington and the fuzzyMatch=true param yields "place_name": "Washington, District of Columbia, United States" while using fuzzyMatch=false yields no results.

False - https://api.mapbox.com/geocoding/v5/mapbox.places/wahsington.json?access_token=pk.abc...&fuzzyMatch=false&types=place

True - https://api.mapbox.com/geocoding/v5/mapbox.places/wahsington.json?access_token=pk.abc...&fuzzyMatch=true&types=place