16
16
17
17
from branca .six import text_type , binary_type
18
18
from 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 )
20
21
21
22
ENV = Environment (loader = PackageLoader ('folium' , 'templates' ))
22
23
@@ -135,8 +136,9 @@ class LegacyMap(MacroElement):
135
136
def __init__ (self , location = None , width = '100%' , height = '100%' ,
136
137
left = "0%" , top = "0%" , position = 'relative' ,
137
138
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 ,
140
142
crs = 'EPSG3857' , control_scale = False ):
141
143
super (LegacyMap , self ).__init__ ()
142
144
self ._name = 'Map'
@@ -163,14 +165,18 @@ def __init__(self, location=None, width='100%', height='100%',
163
165
self .max_lat = max_lat
164
166
self .min_lon = min_lon
165
167
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
166
172
167
173
self .crs = crs
168
174
self .control_scale = control_scale
169
175
170
176
if tiles :
171
177
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 )
174
180
175
181
self ._template = Template (u"""
176
182
{% macro header(this, kwargs) %}
@@ -189,20 +195,26 @@ def __init__(self, location=None, width='100%', height='100%',
189
195
190
196
{% macro script(this, kwargs) %}
191
197
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
+ });
203
215
{% if this.control_scale %}L.control.scale().addTo({{this.get_name()}});{% endif %}
204
216
{% endmacro %}
205
- """ )
217
+ """ ) # noqa
206
218
207
219
def _repr_html_ (self , ** kwargs ):
208
220
"""Displays the Map in a Jupyter notebook.
@@ -217,8 +229,10 @@ def _repr_html_(self, **kwargs):
217
229
218
230
def add_tile_layer (self , tiles = 'OpenStreetMap' , name = None ,
219
231
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 ):
222
236
"""Add a tile layer to the map.
223
237
224
238
See TileLayer for options."""
@@ -232,7 +246,9 @@ def add_tile_layer(self, tiles='OpenStreetMap', name=None,
232
246
tile_layer = TileLayer (tiles = tiles , name = name ,
233
247
min_zoom = min_zoom , max_zoom = max_zoom ,
234
248
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 )
236
252
self .add_child (tile_layer , name = tile_layer .tile_name )
237
253
238
254
def render (self , ** kwargs ):
@@ -333,7 +349,8 @@ class TileLayer(Layer):
333
349
"""
334
350
def __init__ (self , tiles = 'OpenStreetMap' , min_zoom = 1 , max_zoom = 18 ,
335
351
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 ):
337
354
self .tile_name = (name if name is not None else
338
355
'' .join (tiles .lower ().strip ().split ()))
339
356
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,
343
360
344
361
self .min_zoom = min_zoom
345
362
self .max_zoom = max_zoom
363
+ self .no_wrap = no_wrap
364
+ self .continuous_world = continuous_world
346
365
347
366
self .detect_retina = detect_retina
348
367
@@ -374,6 +393,8 @@ def __init__(self, tiles='OpenStreetMap', min_zoom=1, max_zoom=18,
374
393
{
375
394
maxZoom: {{this.max_zoom}},
376
395
minZoom: {{this.min_zoom}},
396
+ continuousWorld: {{this.continuous_world.__str__().lower()}},
397
+ noWrap: {{this.no_wrap.__str__().lower()}},
377
398
attribution: '{{this.attr}}',
378
399
detectRetina: {{this.detect_retina.__str__().lower()}}
379
400
}
0 commit comments