Adjusting the Starting Location and Zoom Level
Sometimes you’ll want to use Folium to create maps of the entire world, but other times, you’ll likely have data for one specific region. You can use the
location parameter of your Folium map to center your map about one particular geolocation. To do so, just pass the tuple of latitude/longitude coordinates to location.
That doesn’t look like New York City. Let’s zoom out a little. This is Kyrgystan, definitely not New York. So what happened here? When using the
location parameter, be sure to pass a tuple that represents northing, easting coordinates.
zoom_start values begin with your map from a wider vantage point, while larger numbers zoom in more. For example, setting
zoom_start equal to
1 gives you a map that’s too zoomed out and actually repeats the continents.
So let’s increase that to
5. This map is still centered about New York City, so now we see the northeast region of the United States. At level
10, we’re really focused on the city, and by
15, we have specific neighborhoods of New York, like Chelsea and the Meatpacking District.
You’ve just set the starting zoom level for your end user. And also keep in mind that the appropriate
zoom_start level will also depend on your screen size, so feel free to continue experimenting until you have a setting that fits your particular need. Once you’ve found settings that work for you, you can save your map as a Python variable and then as an HTML file.
03:06 You now know how to focus your Folium map on a specific region by adjusting its geolocation and zoom. Up next, you’ll learn how to add geographic boundaries to your map by layering in data from a GeoJSON file.
Become a Member to join the conversation.