如何获取邮政信箱的位置?

huangapple go评论89阅读模式
英文:

How do I get the location of a P.O. Box?

问题

我正在使用Azure Maps,当我提供一个邮箱地址时,它告诉我无法提供其经纬度信息。我需要这个信息来在粗略距离内查找物品,所以我更倾向于获取实际邮局的经纬度,但区域内的任何信息都可以。

我该如何实现这一点?

英文:

I am using Azure Maps and when I give it a P.O. Box, it tells me it cannot provide a longitude & latitude for it. I need this for find stuff within a rough distance and so I'd prefer the lat/long of the actual post office, but anything in the area would work.

How can I accomplish this?

答案1

得分: 0

你可以使用以下Python代码获取美国邮局的纬度和经度。

代码:

from azure.maps.search import MapsSearchClient
from azure.core.credentials import AzureKeyCredential

# 设置地址
address = "United States Postal Service"
subscription_key = "你的Azure地图订阅密钥"
search_api = MapsSearchClient(credential=AzureKeyCredential(subscription_key))
response = search_api.search_address(query=address)
if len(response.results) > 0:
    print(f"坐标: {response.results[0].position.lat},{response.results[0].position.lon}")

输出:

坐标: 43.62057,-70.32654

如何获取邮政信箱的位置?

地图:

如何获取邮政信箱的位置?

参考链接:

如何使用Python REST SDK(预览版)创建Azure地图应用程序 - Azure Maps | Microsoft Learn

英文:

> I need this to find stuff within a rough distance and so I'd prefer the lat/long of the actual post office

You can use the below python code to get the latitude and longitude of the post office in the USA.

Code:

from azure.maps.search import MapsSearchClient
from azure.core.credentials import AzureKeyCredential

# Set the address
address = "United States Postal Service"
subscription_key = "Your azure map subscription-key "
search_api =MapsSearchClient(credential=AzureKeyCredential(subscription_key))
response = search_api.search_address(query=address)
if len(response.results) > 0:
    print(f"Coordinate: {response.results[0].position.lat},{response.results[0].position.lon}")

Output:

Coordinate: 43.62057,-70.32654

如何获取邮政信箱的位置?

Map:

如何获取邮政信箱的位置?

Reference:

How to create Azure Maps applications using the Python REST SDK (preview) - Azure Maps | Microsoft Learn

答案2

得分: 0

美国邮政信箱通常无法进行地理编码。最多,如果您知道邮政信箱所在的地址,可以将该地址输入。这不是Azure地图特定的限制,而是一般性的限制。关于邮政信箱有许多奇怪的情况(它们可能会被移动到其他地址)。

英文:

US PO Boxes are not generally geocodable. At best, if you have the address the PO Box is located at, you can put that address in. This is not an Azure Maps specific limitation but a general limitation. There are a lot of funky things that go on with PO Boxes (they can be moved to other addresses).

huangapple
  • 本文由 发表于 2023年6月22日 08:14:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76527883.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定