Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python folium map setting (prevent zooming and panning)

Tags:

python

folium

I'm having some issues figuring out if folium can be restricted to a single instance of the world rather than allowing for panning and zooming into other instances?

What I mean is when I try some basic examples online, I get maps that looks like this when zoomed out:

enter image description here

While the output I want would only have one instance of each continent in the map rather than repeating them when panning / zooming out.

I used the following code to generate the linked image:

import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import folium

#df_traffic = pd.read_csv('../input/ukTrafficAADF.csv')
df_acc = pd.read_csv('../input/accidents_2005_to_2007.csv', dtype=object)
map_hooray = folium.Map(location=[51.5074, 0.1278],
                    zoom_start = 11) # Uses lat then lon. The bigger the zoom number, the closer in you get
map_hooray # Calls the map to display

What modifications do I need to make the map only display one instance of the continents even when zoomed out?

Thanks!

like image 704
Andy Avatar asked Nov 05 '25 17:11

Andy


1 Answers

you should try in your notebook:

import folium

m = folium.Map(location=[-23, -46],
               zoom_start=5,
               zoom_control=False,
               scrollWheelZoom=False,
               dragging=False)

m

More info could be found here: https://leafletjs.com/reference-1.6.0.html#map

(if the url is breaking, change the reference number to the newest version =))

like image 187
user3692586 Avatar answered Nov 07 '25 09:11

user3692586



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!