diff --git a/python/basemap/README.md b/python/basemap/README.md new file mode 100644 index 0000000..cc42aa1 --- /dev/null +++ b/python/basemap/README.md @@ -0,0 +1,55 @@ +# **Creating Interactive Maps with Folium** + +This project demonstrates how to create interactive maps using the Python library **Folium**. Folium is a powerful tool for building maps with markers, popups, and other interactive features. + +![Folium basemap](basemap-folium.jpg) + +--- + +## **Requirements** + +Ensure you have the following installed: + +1. Python 3.7 or higher +2. pip (Python package manager) + +--- + +## **Setup Instructions** + +### 1. Clone the Repository + +```bash +git clone https://github.com/geoapify/maps-api-code-samples.git +cd maps-api-code-samples/python +``` + +### 2. Create a Virtual Environment (Optional) + +It’s recommended to use a virtual environment to avoid dependency conflicts: + +```bash +python -m venv env +source env/bin/activate # On Windows: env\Scripts\activate +``` + +### 3. Install Folium + +Install the Folium library using pip: + +```bash +pip install folium +``` + +--- + +## **Running the Example** + +Run the script to generate an interactive map: + +```bash +python basemap-folium.py +``` +This will create an HTML file named `folium_map.html`. Open it in your browser to view the map. + +--- diff --git a/python/basemap/basemap-folium.jpg b/python/basemap/basemap-folium.jpg new file mode 100644 index 0000000..2fa75b8 Binary files /dev/null and b/python/basemap/basemap-folium.jpg differ diff --git a/python/basemap/basemap-folium.py b/python/basemap/basemap-folium.py new file mode 100644 index 0000000..41c717b --- /dev/null +++ b/python/basemap/basemap-folium.py @@ -0,0 +1,23 @@ +import folium + +# Variables for map configuration +location = [48.8584, 2.2945] # Latitude and Longitude of the Eiffel Tower +zoom_level = 15 +marker_popup = "Eiffel Tower" +marker_color = "red" +output_file = "../../../geoapfiy-maps/pythonProject/folium_map.html" + +# Create a Folium map centered on the location +map_folium = folium.Map(location=location, zoom_start=zoom_level) + +# Add a marker at the specified location +folium.Marker( + location=location, + popup=marker_popup, + icon=folium.Icon(color=marker_color), +).add_to(map_folium) + +# Save the map as an HTML file +map_folium.save(output_file) + +print(f"Map created! Open {output_file} to view it.")