英文:
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:
答案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).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论