23 lines
747 B
Python
23 lines
747 B
Python
|
#!/usr/bin/env python3
|
||
|
|
||
|
import folium
|
||
|
from geopy.geocoders import Nominatim
|
||
|
|
||
|
# Fonction pour obtenir la latitude et la longitude à partir d'une adresse
|
||
|
def get_location(address):
|
||
|
geolocator = Nominatim(user_agent="GEOMAPpy")
|
||
|
location = geolocator.geocode(address)
|
||
|
return location.latitude, location.longitude
|
||
|
|
||
|
adresse = input("Entrez une adresse : ")
|
||
|
lat, long = get_location(adresse)
|
||
|
|
||
|
# Créer une carte centrée autour de la localisation
|
||
|
m = folium.Map(location=[lat, long], zoom_start=15)
|
||
|
|
||
|
# Ajouter un marqueur à la carte
|
||
|
folium.Marker([lat, long], popup=adresse).add_to(m)
|
||
|
|
||
|
# Sauvegarder la carte dans un fichier HTML et afficher les coordonnées
|
||
|
m.save("map.html")
|
||
|
print(f"Coordonnées de l'adresse {adresse} : {lat}, {long}")
|