After few months of busy schedule in college, Today I got the time to sit back and play with python applications. So I started learning WebMaps with python and folium.
We need to pip install folium, after that we import it in the project. How folium works is – Everything spins around a map object, So we create a map object and store it in a variable.
import folium map = folium.Map
Here folium.Map is the class that creates the object “map”. You can do dir (folium) to see different functions and you will find Map there. Then we can do help (folium.Map) to get the parameters and what we can give in that class.
In the parameters we see the Location attribute to specify the coordinates on the world Map.Width- which means you can specify the width of map to be displayed on browser window, otherwise 100% by default means it uses full browser window to display.Tiles is background of map and so on.
So We can give the location attribute and see the location. In the location attribute the coordinates are given as [latitude, longitude].
import folium map = folium.Map([-90 , 50])
Now we have a map object in python code but it is not converted to HTML. So we point the map object and use save method to save it in the html form, creating a new html file. Map will be created in HTML format, So html is containing all the elements that render on the browser.
import folium map = folium.Map([-50 , 50]) map.save("Map1.html")
So I got a Map1.html file having the map of my latitude and longitude mentioned and as it is interactive mapping we can zoom in and out to see more details. Zoom parameter can also be added as (zoom_start = 6) and see changes with different zoom factors.