javascript - Mapbox API:如何获取给定邮政编码下的地址列表?
问题描述
正如问题一样 - 我有一个给定的邮政编码,我需要使用 Mapbox API 获取地址列表
请求以下端点后:
`https://api.mapbox.com/geocoding/v5/mapbox.places/${postcode}.json?types=postcode&access_token=${mapboxToken}`
我得到以下回复:
[
{
"id":"postcode.17660822408923720",
"type":"Feature",
"place_type":[
"postcode"
],
"relevance":1,
"properties":{
},
"text":"HP1 3EN",
"place_name":"HP1 3EN, Hemel Hempstead, Hertfordshire, England, United Kingdom",
"matching_text":"HP13EN",
"matching_place_name":"HP13EN, Hemel Hempstead, Hertfordshire, England, United Kingdom",
"bbox":[
-0.489006,
51.760773,
-0.487601,
51.761635
],
"center":[
-0.488395,
51.7610944
],
"geometry":{
"type":"Point",
"coordinates":[
-0.488395,
51.7610944
]
},
"context":[
{
"id":"place.15727584894798730",
"wikidata":"Q3532",
"text":"Hemel Hempstead"
},
{
"id":"district.8002140812776250",
"wikidata":"Q3410",
"text":"Hertfordshire"
},
{
"id":"region.13483278848453920",
"wikidata":"Q21",
"short_code":"GB-ENG",
"text":"England"
},
{
"id":"country.12405201072814600",
"wikidata":"Q145",
"short_code":"gb",
"text":"United Kingdom"
}
]
}
]
在此响应中,没有关于给定邮政编码下的地址的任何信息。
当我在 URL 查询中指定“地址”类型时,它会得到一个空数组作为响应。
`https://api.mapbox.com/geocoding/v5/mapbox.places/${postcode}.json?types=address&access_token=${mapboxToken}`
我在Mapbox 文档中找不到帮助,有人可以帮我解决这个问题吗?
解决方案
听起来您正在尝试获取给定邮政编码中每个地址的列表?你不能用 Mapbox 做到这一点。
我怀疑您会找到任何允许您执行此操作的地理编码服务。
推荐阅读
- javascript - PHP提交中的重写按钮
- python - 在一个类的多个函数中使用相同的变量-TWS
- php - 在 Drupal 9 中将带有子域的 URL 更改为带有子文件夹的 URL 的最简单方法是什么?
- javascript - Chart.js 与数据库中的数据集
- python - gcloud app.yaml 资源的 Python 设置
- amazon-web-services - 带有 cloudflare 和 ingress-nginx 的 X-Forwarded-For 标头无效
- pandas - 如何以随机格式更改熊猫中的列?
- javascript - 将数组项推送到对象。Javascript
- power-automate - 多条件电源自动化
- go - Go中http.Response接收器函数的语义方式