@@ -31,19 +31,22 @@ class TileLayer(Layer):
31
31
tiles: str, default 'OpenStreetMap'
32
32
Map tileset to use. Can choose from this list of built-in tiles:
33
33
- "OpenStreetMap"
34
- - "Mapbox Bright" (Limited levels of zoom for free tiles)
35
- - "Mapbox Control Room" (Limited levels of zoom for free tiles)
36
- - "Stamen" (Terrain, Toner, and Watercolor )
34
+ - "Stamen Terrain", "Stamen Toner", "Stamen Watercolor"
35
+ - "CartoDB positron", "CartoDB dark_matter"
36
+ - "Mapbox Bright", "Mapbox Control Room" (Limited zoom )
37
37
- "Cloudmade" (Must pass API key)
38
38
- "Mapbox" (Must pass API key)
39
- - "CartoDB" (positron and dark_matter)
40
39
41
40
You can pass a custom tileset to Folium by passing a Leaflet-style
42
41
URL to the tiles parameter: ``http://{s}.yourtiles.com/{z}/{x}/{y}.png``
42
+ You must then also provide attribution, use the `attr` keyword.
43
43
min_zoom: int, default 0
44
44
Minimum allowed zoom level for this tile layer.
45
45
max_zoom: int, default 18
46
46
Maximum allowed zoom level for this tile layer.
47
+ max_native_zoom: int, default None
48
+ The highest zoom level at which the tile server can provide tiles.
49
+ If provided you can zoom in past this level. Else tiles will turn grey.
47
50
attr: string, default None
48
51
Map tile attribution; only required if passing custom tile URL.
49
52
API_key: str, default None
@@ -63,8 +66,8 @@ class TileLayer(Layer):
63
66
64
67
"""
65
68
def __init__ (self , tiles = 'OpenStreetMap' , min_zoom = 0 , max_zoom = 18 ,
66
- attr = None , API_key = None , detect_retina = False ,
67
- name = None , overlay = False ,
69
+ max_native_zoom = None , attr = None , API_key = None ,
70
+ detect_retina = False , name = None , overlay = False ,
68
71
control = True , no_wrap = False , subdomains = 'abc' ):
69
72
self .tile_name = (name if name is not None else
70
73
'' .join (tiles .lower ().strip ().split ()))
@@ -73,33 +76,31 @@ def __init__(self, tiles='OpenStreetMap', min_zoom=0, max_zoom=18,
73
76
self ._name = 'TileLayer'
74
77
self ._env = ENV
75
78
76
- options = {
77
- 'minZoom' : min_zoom ,
78
- 'maxZoom' : max_zoom ,
79
- 'noWrap' : no_wrap ,
80
- 'attribution' : attr ,
81
- 'subdomains' : subdomains ,
82
- 'detectRetina' : detect_retina ,
83
- }
79
+ options = {'minZoom' : min_zoom ,
80
+ 'maxZoom' : max_zoom ,
81
+ 'maxNativeZoom' : max_native_zoom or max_zoom ,
82
+ 'noWrap' : no_wrap ,
83
+ 'attribution' : attr ,
84
+ 'subdomains' : subdomains ,
85
+ 'detectRetina' : detect_retina }
84
86
self .options = json .dumps (options , sort_keys = True , indent = 2 )
85
87
86
- self . tiles = '' .join (tiles .lower ().strip ().split ())
87
- if self . tiles in ('cloudmade' , 'mapbox' ) and not API_key :
88
+ tiles_flat = '' .join (tiles .lower ().strip ().split ())
89
+ if tiles_flat in ('cloudmade' , 'mapbox' ) and not API_key :
88
90
raise ValueError ('You must pass an API key if using Cloudmade'
89
91
' or non-default Mapbox tiles.' )
90
92
templates = list (self ._env .list_templates (
91
93
filter_func = lambda x : x .startswith ('tiles/' )))
92
- tile_template = 'tiles/' + self . tiles + '/tiles.txt'
93
- attr_template = 'tiles/' + self . tiles + '/attr.txt'
94
+ tile_template = 'tiles/' + tiles_flat + '/tiles.txt'
95
+ attr_template = 'tiles/' + tiles_flat + '/attr.txt'
94
96
95
97
if tile_template in templates and attr_template in templates :
96
98
self .tiles = self ._env .get_template (tile_template ).render (API_key = API_key ) # noqa
97
99
self .attr = self ._env .get_template (attr_template ).render ()
98
100
else :
99
101
self .tiles = tiles
100
102
if not attr :
101
- raise ValueError ('Custom tiles must'
102
- ' also be passed an attribution.' )
103
+ raise ValueError ('Custom tiles must have an attribution.' )
103
104
if isinstance (attr , binary_type ):
104
105
attr = text_type (attr , 'utf8' )
105
106
self .attr = attr
@@ -111,7 +112,7 @@ def __init__(self, tiles='OpenStreetMap', min_zoom=0, max_zoom=18,
111
112
{{ this.options }}
112
113
).addTo({{this._parent.get_name()}});
113
114
{% endmacro %}
114
- """ ) # noqa
115
+ """ )
115
116
116
117
117
118
class WmsTileLayer (Layer ):
0 commit comments