我有一个使用Python Flask开发的项目,它可以使用Google地图找到附近所有的服装店。
到目前为止,我可以用我的代码做到这一点,但我目前的位置是从我的IP地址,这个IP地址来自互联网服务提供商,所以。。我不想要。。因为互联网服务提供商离我的位置不太近,所以我想要更精确的位置,可以得到当前用户的GPS。。
所以我的问题。。烧瓶能做到吗。。?,如果没有..其他的解决方案是什么。。?
以下是获取当前ISP位置并查找所有附近位置的代码:
import googlemaps
import geocoder
from googleplaces import GooglePlaces, types
# you can get the API KEY here:
# https://developers.google.com/console
API_KEY = 'MY_API_KEY'
gmaps = googlemaps.Client(key=API_KEY)
locations = gmaps.geolocate()
latitude = locations['location']['lat']
longitude = locations['location']['lng']
g = geocoder.google([latitude, longitude], method='reverse')
get_json_values = g.json
my_current_position = get_json_values['address']
google_places = GooglePlaces(API_KEY)
query_result = google_places.nearby_search(
location=my_current_position,
keyword='baju', radius=3200)
for place in query_result.places:
print(place.name)
place.get_details()
print(place.url)