@@ -21,7 +21,7 @@ def __init__(self, location=None, width='100%', height='100%',
21
21
left = "0%" , top = "0%" , position = 'relative' ,
22
22
tiles = 'OpenStreetMap' , API_key = None , max_zoom = 18 , min_zoom = 1 ,
23
23
zoom_start = 10 , attr = None , min_lat = - 90 , max_lat = 90 ,
24
- min_lon = - 180 , max_lon = 180 ):
24
+ min_lon = - 180 , max_lon = 180 , detect_retina = False ):
25
25
"""Create a Map with Folium and Leaflet.js
26
26
27
27
Generate a base map of given width and height with either default
@@ -58,6 +58,9 @@ def __init__(self, location=None, width='100%', height='100%',
58
58
Initial zoom level for the map.
59
59
attr: string, default None
60
60
Map tile attribution; only required if passing custom tile URL.
61
+ detect_retina: bool, default False
62
+ If true and user is on a retina display, it will request four tiles of half the specified
63
+ size and a bigger zoom level in place of one to utilize the high resolution.
61
64
62
65
Returns
63
66
-------
@@ -102,7 +105,7 @@ def __init__(self, location=None, width='100%', height='100%',
102
105
self .max_lon = max_lon
103
106
104
107
self .add_tile_layer (tiles = tiles , min_zoom = min_zoom , max_zoom = max_zoom ,
105
- attr = attr , API_key = API_key )
108
+ attr = attr , API_key = API_key , detect_retina = detect_retina )
106
109
107
110
self ._template = Template (u"""
108
111
{% macro header(this, kwargs) %}
@@ -148,7 +151,7 @@ def _repr_html_(self, **kwargs):
148
151
def add_tile_layer (self , tiles = 'OpenStreetMap' , name = None ,
149
152
API_key = None , max_zoom = 18 , min_zoom = 1 ,
150
153
attr = None , tile_name = None , tile_url = None ,
151
- active = False , ** kwargs ):
154
+ active = False , detect_retina = False , ** kwargs ):
152
155
if tile_name is not None :
153
156
name = tile_name
154
157
warnings .warn ("'tile_name' is deprecated. Please use 'name' instead." )
@@ -158,12 +161,13 @@ def add_tile_layer(self, tiles='OpenStreetMap', name=None,
158
161
159
162
tile_layer = TileLayer (tiles = tiles , name = name ,
160
163
min_zoom = min_zoom , max_zoom = max_zoom ,
161
- attr = attr , API_key = API_key )
164
+ attr = attr , API_key = API_key , detect_retina = detect_retina )
162
165
self .add_children (tile_layer , name = tile_layer .tile_name )
163
166
164
167
class TileLayer (MacroElement ):
165
168
def __init__ (self , tiles = 'OpenStreetMap' , name = None ,
166
- min_zoom = 1 , max_zoom = 18 , attr = None , API_key = None , overlay = False ):
169
+ min_zoom = 1 , max_zoom = 18 , attr = None , API_key = None , overlay = False ,
170
+ detect_retina = False ):
167
171
"""TODO docstring here
168
172
Parameters
169
173
----------
@@ -176,6 +180,7 @@ def __init__(self, tiles='OpenStreetMap', name=None,
176
180
self .max_zoom = max_zoom
177
181
178
182
self .overlay = overlay
183
+ self .detect_retina = detect_retina
179
184
180
185
self .tiles = '' .join (tiles .lower ().strip ().split ())
181
186
if self .tiles in ('cloudmade' , 'mapbox' ) and not API_key :
@@ -204,7 +209,8 @@ def __init__(self, tiles='OpenStreetMap', name=None,
204
209
{
205
210
maxZoom: {{this.max_zoom}},
206
211
minZoom: {{this.min_zoom}},
207
- attribution: '{{this.attr}}'
212
+ attribution: '{{this.attr}}',
213
+ detectRetina: {{this.detect_retina.__str__().lower()}}
208
214
}
209
215
).addTo({{this._parent.get_name()}});
210
216
0 commit comments