简体   繁体   English

如何在OSM中使用python获取我的经纬度?

[英]How can I use python to get my lat,lon in OSM?

I have try geocode to get my lat and lon , but not current 我已经尝试使用地理编码来获取我的经纬度,但是不是最新的

it is get by my ip and conver to lat,lon 它是通过我的IP转换到lat,lon

Can help me osm(openstreetmap) api can get my current lat and lon? 可以帮助我osm(openstreetmap)api获取我当前的经纬度吗?

import geocoder
g = geocoder.ip('me')
print(g.latlng)

and

freegeoip = "http://freegeoip.net/json"
geo_r = requests.get(freegeoip)
geo_json = geo_r.json()

user_postition = [geo_json["latitude"], geo_json["longitude"]]

print(user_postition)

OpenStreetMap doesn't offer a geolocation API. OpenStreetMap不提供地理位置API。 However you can find various geolocation services and databases on the Internet. 但是,您可以在Internet上找到各种地理位置服务和数据库。 Some of them are mentioned here: https://opendata.stackexchange.com/questions/2087/ip-geocoding-data-sources-and-or-apis 这里提到其中一些: https : //opendata.stackexchange.com/questions/2087/ip-geocoding-data-sources-and-or-apis

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM