perliedman / leaflet-control-geocoder

A simple geocoder form to locate places. Easily extended to multiple data providers.
http://www.liedman.net/leaflet-control-geocoder/
BSD 2-Clause "Simplified" License
564 stars 221 forks source link

what3words no longer working #332

Open rogercreagh opened 2 years ago

rogercreagh commented 2 years ago

w3w api v2 is deprecated and returns an 403 error to the call for example https://api.what3words.com//v2/forward?key=XXXXXX&addr=casino.galloping.pai

need to update to v3 api which would use for example https://api.what3words.com/v3/autosuggest?key=XXXXXX&input=casino.galloping.pai

simply using the serviceUrl: https://api.what3words.com/v3/ option doesn't work as it is being generated as https://api.what3words.com/v3/forward?key=XXXXXX&addr=casino.galloping.pai which, not surprisingly gives a 404 error

there are also some useful additional options which could be passed for example &language=en&focus=51.03,-2.90 to specify the language for the match and an approximate location, for example to give preference to partial matched nearest the current centre of the map

Simply changing what3words.ts:19 to specify 'v3' in place of 'v2' and what3words.ts:29 to replace 'forward' with 'autosuggest' and what3words.ts:32 to replace 'addr' with 'input' would get the basic back on track I think.

actually looking at it I think it will be a bit more complex as the returned data is a json with the closest suggestions which probably has a different format to v2 api... https://developer.what3words.com/public-api/docs#autosuggest

You might be better off implementing the simpler contvert-to-coordinates call as an alternative which requires the full 3 word address and you don't have to handle multiple suggestions https://developer.what3words.com/public-api/docs#convert-to-coords