[英]How can I get all possible addresses with lat and long by city or district prefix?
I want to implement code like below:我想实现如下代码:
When I send request to endpoint with name of " Sig " (just an example),I need it to give me当我向名为“ Sig ”的端点发送请求时(只是一个例子),我需要它给我
[
{
"name ":"Sighisoara",
"lat":"smth",
"Long":"smth"
},
{
"name ":"Sigulda",
"lat":"smth",
"Long":"smth"
}
]
Currently, I use OpenStreetMap , It has no such functionality.目前,我使用OpenStreetMap ,它没有这样的功能。 To get a address, you should write exactly how the address is spelled.
要获得地址,您应该准确地写出地址的拼写方式。 For example, to get Sighisoara , you need to write Sighisoara Any idea to do that or free api which provides such functionality.
例如,要获得Sighisoara ,您需要编写Sighisoara Any idea 来执行此操作或免费提供此类功能的api 。
PS, I am using Python. PS,我正在使用 Python。
I think the point is for you to understand the structure of this dictionary that contains all the city names,and you can try to split the structures.我认为重点是让你理解这个包含所有城市名称的字典的结构,你可以尝试拆分结构。 For example, I got a dictionary of weather from an API here, and I want to print out the current temperature.
例如,我从这里的 API 得到了天气字典,我想打印出当前温度。
weather ={'coord': {'lon': 113.25, 'lat': 23.1167}, 'weather': [{'id': 803, 'main': 'Clouds', 'description': 'broken clouds', 'icon': '04d'}], 'base': 'stations', 'main': {'temp': 298.18, 'feels_like': 298.31, 'temp_min': 295.37, 'temp_max': 299.82, 'pressure': 1018, 'humidity': 53}, 'visibility': 6000, 'wind': {'speed': 2, 'deg': 160}, 'clouds': {'all': 75}, 'dt': 1615355271, 'sys': {'type': 1, 'id': 9620, 'country': 'CN', 'sunrise': 1615329655, 'sunset': 1615372438}, 'timezone': 28800, 'id': 1809858, 'name': 'Guangzhou', 'cod': 200} This is the code I will use: current_temp = (weather['main']['temp']) The name of this dictionary is weather, inside of it, there are several lists of 'main', which contained the 'temp' I want. weather ={'coord': {'lon': 113.25, 'lat': 23.1167}, 'weather': [{'id': 803, 'main': 'Clouds', 'description': '破云', 'icon': '04d'}], 'base': 'stations', 'main': {'temp': 298.18, 'feels_like': 298.31, 'temp_min': 295.37, 'temp_max': 299.82, 'pressure' : 1018, '湿度': 53}, '能见度': 6000, '风': {'speed': 2, 'deg': 160}, 'clouds': {'all': 75}, 'dt': 1615355271, 'sys': {'type': 1, 'id': 9620, 'country': 'CN', 'sunrise': 1615329655, 'sunset': 1615372438}, 'timezone': 28800, 'id': 1809858, 'name': 'Guangzhou', 'cod': 200} 这是我将使用的代码: current_temp = (weather['main']['temp']) 这个字典的名字是weather,在里面,有几个'main'列表,其中包含我想要的'temp'。 So you can make sure if your code is correctly catch the structure.
因此,您可以确保您的代码是否正确捕获了结构。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.