1616
1717from branca .six import text_type , binary_type
1818from branca .utilities import _parse_size
19- from branca .element import Element , Figure , MacroElement , Html , JavascriptLink , CssLink
19+ from branca .element import (Element , Figure , MacroElement , Html ,
20+ JavascriptLink , CssLink )
2021
2122ENV = Environment (loader = PackageLoader ('folium' , 'templates' ))
2223
@@ -135,8 +136,9 @@ class LegacyMap(MacroElement):
135136 def __init__ (self , location = None , width = '100%' , height = '100%' ,
136137 left = "0%" , top = "0%" , position = 'relative' ,
137138 tiles = 'OpenStreetMap' , API_key = None , max_zoom = 18 , min_zoom = 1 ,
138- zoom_start = 10 , attr = None , min_lat = - 90 , max_lat = 90 ,
139- min_lon = - 180 , max_lon = 180 , detect_retina = False ,
139+ zoom_start = 10 , continuous_world = False , world_copy_jump = False ,
140+ no_wrap = False , attr = None , min_lat = - 90 , max_lat = 90 ,
141+ min_lon = - 180 , max_lon = 180 , max_bounds = True , detect_retina = False ,
140142 crs = 'EPSG3857' , control_scale = False ):
141143 super (LegacyMap , self ).__init__ ()
142144 self ._name = 'Map'
@@ -163,14 +165,18 @@ def __init__(self, location=None, width='100%', height='100%',
163165 self .max_lat = max_lat
164166 self .min_lon = min_lon
165167 self .max_lon = max_lon
168+ self .max_bounds = max_bounds
169+ self .continuous_world = continuous_world
170+ self .no_wrap = no_wrap
171+ self .world_copy_jump = world_copy_jump
166172
167173 self .crs = crs
168174 self .control_scale = control_scale
169175
170176 if tiles :
171177 self .add_tile_layer (tiles = tiles , min_zoom = min_zoom , max_zoom = max_zoom ,
172- attr = attr , API_key = API_key ,
173- detect_retina = detect_retina )
178+ continuous_world = continuous_world , no_wrap = no_wrap ,
179+ attr = attr , API_key = API_key , detect_retina = detect_retina )
174180
175181 self ._template = Template (u"""
176182 {% macro header(this, kwargs) %}
@@ -189,20 +195,26 @@ def __init__(self, location=None, width='100%', height='100%',
189195
190196 {% macro script(this, kwargs) %}
191197
192- var southWest = L.latLng({{ this.min_lat }}, {{ this.min_lon }});
193- var northEast = L.latLng({{ this.max_lat }}, {{ this.max_lon }});
194- var bounds = L.latLngBounds(southWest, northEast);
195-
196- var {{this.get_name()}} = L.map('{{this.get_name()}}', {
197- center:[{{this.location[0]}},{{this.location[1]}}],
198- zoom: {{this.zoom_start}},
199- maxBounds: bounds,
200- layers: [],
201- crs: L.CRS.{{this.crs}}
202- });
198+ {% if this.max_bounds %}
199+ var southWest = L.latLng({{ this.min_lat }}, {{ this.min_lon }});
200+ var northEast = L.latLng({{ this.max_lat }}, {{ this.max_lon }});
201+ var bounds = L.latLngBounds(southWest, northEast);
202+ {% else %}
203+ var bounds = null;
204+ {% endif %}
205+
206+ var {{this.get_name()}} = L.map(
207+ '{{this.get_name()}}',
208+ {center: [{{this.location[0]}},{{this.location[1]}}],
209+ zoom: {{this.zoom_start}},
210+ maxBounds: bounds,
211+ layers: [],
212+ worldCopyJump: {{this.world_copy_jump.__str__().lower()}},
213+ crs: L.CRS.{{this.crs}}
214+ });
203215 {% if this.control_scale %}L.control.scale().addTo({{this.get_name()}});{% endif %}
204216 {% endmacro %}
205- """ )
217+ """ ) # noqa
206218
207219 def _repr_html_ (self , ** kwargs ):
208220 """Displays the Map in a Jupyter notebook.
@@ -217,8 +229,10 @@ def _repr_html_(self, **kwargs):
217229
218230 def add_tile_layer (self , tiles = 'OpenStreetMap' , name = None ,
219231 API_key = None , max_zoom = 18 , min_zoom = 1 ,
220- attr = None , tile_name = None , tile_url = None ,
221- active = False , detect_retina = False , ** kwargs ):
232+ continuous_world = False , attr = None ,
233+ tile_name = None , tile_url = None ,
234+ active = False , detect_retina = False , no_wrap = False ,
235+ ** kwargs ):
222236 """Add a tile layer to the map.
223237
224238 See TileLayer for options."""
@@ -232,7 +246,9 @@ def add_tile_layer(self, tiles='OpenStreetMap', name=None,
232246 tile_layer = TileLayer (tiles = tiles , name = name ,
233247 min_zoom = min_zoom , max_zoom = max_zoom ,
234248 attr = attr , API_key = API_key ,
235- detect_retina = detect_retina )
249+ detect_retina = detect_retina ,
250+ continuous_world = continuous_world ,
251+ no_wrap = no_wrap )
236252 self .add_child (tile_layer , name = tile_layer .tile_name )
237253
238254 def render (self , ** kwargs ):
@@ -333,7 +349,8 @@ class TileLayer(Layer):
333349 """
334350 def __init__ (self , tiles = 'OpenStreetMap' , min_zoom = 1 , max_zoom = 18 ,
335351 attr = None , API_key = None , detect_retina = False ,
336- name = None , overlay = False , control = True ):
352+ continuous_world = False , name = None , overlay = False ,
353+ control = True , no_wrap = False ):
337354 self .tile_name = (name if name is not None else
338355 '' .join (tiles .lower ().strip ().split ()))
339356 super (TileLayer , self ).__init__ (name = self .tile_name , overlay = overlay ,
@@ -343,6 +360,8 @@ def __init__(self, tiles='OpenStreetMap', min_zoom=1, max_zoom=18,
343360
344361 self .min_zoom = min_zoom
345362 self .max_zoom = max_zoom
363+ self .no_wrap = no_wrap
364+ self .continuous_world = continuous_world
346365
347366 self .detect_retina = detect_retina
348367
@@ -374,6 +393,8 @@ def __init__(self, tiles='OpenStreetMap', min_zoom=1, max_zoom=18,
374393 {
375394 maxZoom: {{this.max_zoom}},
376395 minZoom: {{this.min_zoom}},
396+ continuousWorld: {{this.continuous_world.__str__().lower()}},
397+ noWrap: {{this.no_wrap.__str__().lower()}},
377398 attribution: '{{this.attr}}',
378399 detectRetina: {{this.detect_retina.__str__().lower()}}
379400 }
0 commit comments