init commit
This commit is contained in:
28
transportmanager/server/utils/maps.py
Normal file
28
transportmanager/server/utils/maps.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from geopy.geocoders import Nominatim
|
||||
|
||||
class AdressCoordinates:
|
||||
def __init__(self, address):
|
||||
self.addess = address
|
||||
|
||||
def open_Maps_by_address(self):
|
||||
address = self.addess
|
||||
if not address:
|
||||
return
|
||||
|
||||
#try:
|
||||
geolocator = Nominatim(user_agent="flet_Maps_app")
|
||||
location = geolocator.geocode(address)
|
||||
print(location)
|
||||
if location:
|
||||
latitude = location.latitude
|
||||
longitude = location.longitude
|
||||
Maps_url = f"https://www.google.com/maps/search/?api=1&query={latitude},{longitude}"
|
||||
|
||||
return {
|
||||
'latitude' : latitude,
|
||||
'longitude' : longitude,
|
||||
'Maps_url': Maps_url
|
||||
}
|
||||
|
||||
#except Exception as ex:
|
||||
# print(ex)
|
||||
Reference in New Issue
Block a user