如何使用 tomtom API 查找邮政编码的坐标

How to find the co-ordinates of a postal code using the tomtom API

这是我正在尝试做的事情:

我看到有一个 FuzzySearchQueryBuilder class 提供,我按以下方式使用它:

FuzzySearchQuery query = FuzzySearchQueryBuilder.create("query")
            .withLanguage(Locale.getDefault().toLanguageTag())
            .withCountry("UK")
            .withExtendedPostalCodes("SN41AB, WF112AB")
            .build();

然而搜索returns出错,抱怨无法成功解析postcode值。

查看各种示例,我没有看到使用 post代码搜索的示例。

我还查看了 Javadocs here,其中讨论了如何使用这些索引值 "PAD, POI, Str, XStr"。但是 post 代码放在哪里呢?

我想做的事情有可能吗? 似乎应该如此,因为 API 专门处理 postal 代码。所以我假设这只是使用正确参数格式的问题。 任何人都可以提供以这种方式使用 API 的示例吗?

documentation for withExtendedPostalCodes 表明此方法的用途与您的示例完全不同:

Indexes for which extended postal codes should be included in the results. Available indexes are: Addr, Geo, PAD, POI, Str, XStr. Value should be a comma separated list of index types (in any order) or "None" for no indexes, i.e. "PAD,Addr,POI"

您在 create 中传递的字符串是应提供地址信息的位置。此外,此处使用的正确国家代码是 "GB" 而不是 "UK"。所以你的代码应该是这样的:

FuzzySearchQuery query = FuzzySearchQueryBuilder.create("SN41AB,WF112AB")
        .withLanguage(Locale.getDefault().toLanguageTag())
        .withCountry("GB")
        .build();

// Do stuff with the results of query.