Here's what I'm trying to do:
- Given a UK postcode as a start and end point, e.g. SN41AB - WF112AB, find the Lat/lon co-ordinates. This is so that I can map a route between the points, and show it on the map.
I see that there's a FuzzySearchQueryBuilder
class provided, which I'm using in the following way:
FuzzySearchQuery query = FuzzySearchQueryBuilder.create("query")
.withLanguage(Locale.getDefault().toLanguageTag())
.withCountry("UK")
.withExtendedPostalCodes("SN41AB, WF112AB")
.build();
However the search returns an error, complaining about not being able to successfully parse the postcode value.
Looking at the various examples, I don't see one that is using a postcode search.
I've also looked at the Javadocs here, which talks about using these index values "PAD, POI, Str, XStr". But where does the post code fit in?
Is what I'm trying to do even possible? It seems like it should be, as the API specifically deals with postal codes. So I'm assuming it's just a question of using the correct parameter format. Could anyone provide an example of using the API in this way?
The documentation for
withExtendedPostalCodes
suggests this method is intended to be used quite differently from your sample:The string you pass in
create
is where address information should be provided. In addition, the correct country code to use here is"GB"
rather than"UK"
. So your code should look something like: