首页 > 解决方案 > HERE Maps matchLevel 参数不起作用

问题描述

我正在尝试仅过滤 HERE Map 的自动完成 API 中的城市。我在他们的文档上读到有matchLevel参数......

但是,如果我包含它,什么都不会改变。

这是我的电话:

http://autocomplete.geocoder.api.here.com/6.2/suggest.json?app_id=MY_APP_ID&app_code=MY_APP_CODE&matchLevel=city&query=New York

我仍然收到非城市类型的回复。

{
    "suggestions": [
        {
            "label": "United States, New York",
            "language": "en",
            "countryCode": "USA",
            "locationId": "NT_rNsDLtnazM.kjVC-K6YWOA",
            "address": {
                "country": "United States",
                "state": "New York"
            },
            "matchLevel": "state"
        },
        {
            "label": "United States, New York, New York, New York",
            "language": "en",
            "countryCode": "USA",
            "locationId": "NT_YpQcXqbaOb.I4m5EW8BHEC",
            "address": {
                "country": "United States",
                "state": "New York",
                "county": "New York",
                "city": "New York",
                "postalCode": "10007"
            },
            "matchLevel": "city"
        },
        {
            "label": "United States, New York, New York",
            "language": "en",
            "countryCode": "USA",
            "locationId": "NT_ABhedB4xGEL83YY5az47iD",
            "address": {
                "country": "United States",
                "state": "New York",
                "county": "New York"
            },
            "matchLevel": "county"
        },
    ...

任何帮助表示赞赏。

标签: here-apihere-maps-rest

解决方案


matchLevel 是响应字段,而不是查询参数。

使用答案的后处理,如 array.filter() 仅保留与“城市”匹配的答案元素


推荐阅读