Folium is built on the data wrangling strengths of the Python ecosystem and the mapping strengths of the Leaflet.js (JavaScript) library. Simply, manipulate your data in Python, then visualize it on a leaflet map via Folium. Folium makes it easy to visualize data that’s been manipulated in Python, on an interactive Leaflet map. This library has a number of built-in tilesets from OpenStreetMap, Mapbox etc.
Command to install folium module :
pip install folium
Code #1 : To create a Base Map.
Python3
import folium
my_map1 = folium. Map (location = [ 28.5011226 , 77.4099794 ],
zoom_start = 12 )
my_map1.save( " my_map1.html " )
|
Output :

Code #2 : Add a circular marker with popup text.
Python3
import folium
my_map2 = folium. Map (location = [ 28.5011226 , 77.4099794 ],
zoom_start = 12 )
folium.CircleMarker(location = [ 28.5011226 , 77.4099794 ],
radius = 50 , popup = ' FRI ' ).add_to(my_map2)
my_map2.save( " my_map2.html " )
|
Output :

Code #3 : Add a simple_marker for parachute style marker with pop-up text.
Python3
import folium
my_map3 = folium. Map (location = [ 28.5011226 , 77.4099794 ],
zoom_start = 15 )
folium.Marker([ 28.5011226 , 77.4099794 ],
popup = ' Geeksforgeeks.org ' ).add_to(my_map3)
my_map3.save( " my_map3.html " )
|
Output :

Code #4 : Add a line to the map
Python3
import folium
my_map4 = folium. Map (location = [ 28.5011226 , 77.4099794 ],
zoom_start = 12 )
folium.Marker([ 28.704059 , 77.102490 ],
popup = 'Delhi' ).add_to(my_map4)
folium.Marker([ 28.5011226 , 77.4099794 ],
popup = 'GeeksforGeeks' ).add_to(my_map4)
folium.PolyLine(locations = [( 28.704059 , 77.102490 ), ( 28.5011226 , 77.4099794 )],
line_opacity = 0.5 ).add_to(my_map4)
my_map4.save( "my_map4.html" )
|
Output :

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
08 Jun, 2021
Like Article
Save Article