@@ -90,13 +90,14 @@ def __init__(self, location=None, width='100%', height='100%',
9090
9191 Examples
9292 --------
93- >>>map = folium.Map(location=[45.523, -122.675], width=750, height=500)
94- >>>map = folium.Map(location=[45.523, -122.675],
95- tiles='Mapbox Control Room')
96- >>>map = folium.Map(location=(45.523, -122.675), max_zoom=20,
97- tiles='Cloudmade', API_key='YourKey')
98- >>>map = folium.Map(location=[45.523, -122.675], zoom_start=2,
99- tiles=('http://{s}.tiles.mapbox.com/v3/'
93+ >>> map = folium.Map(location=[45.523, -122.675], width=750,
94+ ... height=500)
95+ >>> map = folium.Map(location=[45.523, -122.675],
96+ tiles='Mapbox Control Room')
97+ >>> map = folium.Map(location=(45.523, -122.675), max_zoom=20,
98+ tiles='Cloudmade', API_key='YourKey')
99+ >>> map = folium.Map(location=[45.523, -122.675], zoom_start=2,
100+ tiles=('http://{s}.tiles.mapbox.com/v3/'
100101 'mapbox.control-room/{z}/{x}/{y}.png'),
101102 attr='Mapbox attribution')
102103
@@ -209,24 +210,46 @@ def __init__(self, location=None, width='100%', height='100%',
209210 self .template_vars .setdefault ('image_layers' , [])
210211
211212 @iter_obj ('simple' )
212- def add_tile_layer (self , tile_name = None , tile_url = None , active = False ):
213- """Adds a simple tile layer.
213+ def add_tile_layer (self , tile_name = None , tile_url = None , ** kw ):
214+ """
215+ Adds a simple tile layer.
214216
215217 Parameters
216218 ----------
217219 tile_name: string
218220 name of the tile layer
219221 tile_url: string
220222 url location of the tile layer
221- active: boolean
222- should the layer be active when added
223+
224+ For the available options see:
225+ http://leafletjs.com/reference.html#tilelayer
226+
223227 """
228+ # Same defaults.
229+ tms = kw .pop ('tms' , False )
230+ minZoom = kw .pop ('minZoom' , 0 )
231+ opacity = kw .pop ('opacity' , 1 )
232+ maxZoom = kw .pop ('maxZoom' , 18 )
233+ noWrap = kw .pop ('noWrap' , False )
234+ zoomOffset = kw .pop ('zoomOffset' , 0 )
235+ zoomReverse = kw .pop ('zoomReverse' , False )
236+ continuousWorld = kw .pop ('continuousWorld' , False )
237+
224238 if tile_name not in self .added_layers :
225239 tile_name = tile_name .replace (" " , "_" )
226240 tile_temp = self .env .get_template ('tile_layer.js' )
227-
228- tile = tile_temp .render ({'tile_name' : tile_name ,
229- 'tile_url' : tile_url })
241+ tile = tile_temp .render ({
242+ 'tile_name' : tile_name ,
243+ 'tile_url' : tile_url ,
244+ 'minZoom' : minZoom ,
245+ 'maxZoom' : maxZoom ,
246+ 'tms' : str (tms ).lower (),
247+ 'continuousWorld' : str (continuousWorld ).lower (),
248+ 'noWrap' : str (noWrap ).lower (),
249+ 'zoomOffset' : zoomOffset ,
250+ 'zoomReverse' : str (zoomReverse ).lower (),
251+ 'opacity' : opacity ,
252+ })
230253
231254 self .template_vars .setdefault ('tile_layers' , []).append ((tile ))
232255
@@ -305,8 +328,8 @@ def simple_marker(self, location=None, popup=None,
305328
306329 Example
307330 -------
308- >>>map.simple_marker(location=[45.5, -122.3], popup='Portland, OR')
309- >>>map.simple_marker(location=[45.5, -122.3], popup=(vis, 'vis.json'))
331+ >>> map.simple_marker(location=[45.5, -122.3], popup='Portland, OR')
332+ >>> map.simple_marker(location=[45.5, -122.3], popup=(vis, 'vis.json'))
310333
311334 """
312335 count = self .mark_cnt ['simple' ]
@@ -364,8 +387,8 @@ def line(self, locations,
364387
365388 Example
366389 -------
367- >>>map.line(locations=[(45.5, -122.3), (42.3, -71.0)])
368- >>>map.line(locations=[(45.5, -122.3), (42.3, -71.0)],
390+ >>> map.line(locations=[(45.5, -122.3), (42.3, -71.0)])
391+ >>> map.line(locations=[(45.5, -122.3), (42.3, -71.0)],
369392 line_color='red', line_opacity=1.0)
370393
371394 """
@@ -409,7 +432,6 @@ def multiline(self, locations, line_color=None, line_opacity=None,
409432
410433 Example
411434 -------
412- # FIXME: Add another example.
413435 >>> m.multiline(locations=[[(45.5236, -122.675), (45.5236, -122.675)],
414436 [(45.5237, -122.675), (45.5237, -122.675)],
415437 [(45.5238, -122.675), (45.5238, -122.675)]])
@@ -467,9 +489,9 @@ def circle_marker(self, location=None, radius=500, popup=None,
467489
468490 Example
469491 -------
470- >>>map.circle_marker(location=[45.5, -122.3],
492+ >>> map.circle_marker(location=[45.5, -122.3],
471493 radius=1000, popup='Portland, OR')
472- >>>map.circle_marker(location=[45.5, -122.3],
494+ >>> map.circle_marker(location=[45.5, -122.3],
473495 radius=1000, popup=(bar_chart, 'bar_data.json'))
474496
475497 """
@@ -584,7 +606,7 @@ def click_for_marker(self, popup=None):
584606
585607 Example
586608 -------
587- >>>map.click_for_marker(popup='Your Custom Text')
609+ >>> map.click_for_marker(popup='Your Custom Text')
588610
589611 """
590612 latlng = '"Latitude: " + lat + "<br>Longitude: " + lng '
@@ -802,9 +824,9 @@ def geo_json(self, geo_path=None, geo_str=None, data_out='data.json',
802824 keyword argument will enable conversion to GeoJSON.
803825 reset: boolean, default False
804826 Remove all current geoJSON layers, start with new layer
805- freescale: if True use free format for the scale, where min and max values
806- are taken from the data. It also allow to plot allow to plot values < 0
807- and float legend labels.
827+ freescale: if True use free format for the scale, where min and max
828+ values are taken from the data. It also allow to plot
829+ values < 0 and float legend labels.
808830
809831 Output
810832 ------
@@ -893,7 +915,7 @@ def json_style(style_cnt, line_color, line_weight, line_opacity,
893915
894916 # D3 Color scale.
895917 series = data [columns [1 ]]
896- if freescale == False :
918+ if not freescale :
897919 if threshold_scale and len (threshold_scale ) > 6 :
898920 raise ValueError
899921 domain = threshold_scale or utilities .split_six (series = series )
@@ -918,18 +940,15 @@ def json_style(style_cnt, line_color, line_weight, line_opacity,
918940
919941 if not freescale :
920942 legend = leg_templ .render ({'lin_min' : 0 ,
921- 'lin_max' : int (domain [- 1 ]* 1.1 ),
922- 'tick_labels' : tick_labels ,
923- 'caption' : name })
924-
925-
943+ 'lin_max' : int (domain [- 1 ]* 1.1 ),
944+ 'tick_labels' : tick_labels ,
945+ 'caption' : name })
926946 else :
927947 legend = leg_templ .render ({'lin_min' : domain [0 ],
928948 'lin_max' : domain [- 1 ],
929949 'tick_labels' : tick_labels ,
930950 'caption' : name })
931951
932-
933952 self .template_vars .setdefault ('map_legends' , []).append (legend )
934953
935954 # Style with color brewer colors.
0 commit comments