26 lines
797 B
Python
Executable File
26 lines
797 B
Python
Executable File
#!/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, lon = get_location(adresse)
|
|
|
|
# Créer une carte centrée autour de la localisation
|
|
m = folium.Map(location=[lat, lon], zoom_start=15)
|
|
|
|
# Ajouter un marqueur à la carte
|
|
folium.Marker(
|
|
[lat, lon],
|
|
popup="<h2>"+adresse+"</h2><h4>"+str([lat, lon])+"</h4>"
|
|
).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}, {lon}") |