19
19
20
20
21
21
class WmsTileLayer (Layer ):
22
- def __init__ (self , url , name = None ,
23
- format = None , layers = None , transparent = True ,
24
- attr = None , overlay = True , control = True ):
25
- """
26
- TODO docstring here
22
+ def __init__ (self , url , format = None , layers = None ,
23
+ transparent = True , attr = None ,
24
+ name = None , overlay = True , control = True ):
25
+ """Creates a Layer based on a WMS (Web map service).
27
26
27
+ Parameters
28
+ ----------
29
+ url: str
30
+ The url of the WMS server.
31
+ format: str, default None
32
+ The format of the service output.
33
+ Ex: 'iamge/png'
34
+ layers: str, default None
35
+ The names of the layers to be displayed.
36
+ transparent: bool, default True
37
+ Whether the layer shall allow transparency.
38
+ attr: str, default None
39
+ The attribution of the service. Will be displayed in the bottom right corner.
40
+ name : string, default None
41
+ The name of the Layer, as it will appear in LayerControls
42
+ overlay : bool, default False
43
+ Whether the layer is optional (overlay) or compulsory.
44
+ control : bool, default True
45
+ Whether the Layer will be included in LayerControls
28
46
"""
29
47
super (WmsTileLayer , self ).__init__ (overlay = overlay , control = control )
30
48
self ._name = 'WmsTileLayer'
@@ -134,9 +152,31 @@ def render(self, **kwargs):
134
152
class Vega (Element ):
135
153
def __init__ (self , data , width = None , height = None ,
136
154
left = "0%" , top = "0%" , position = 'relative' ):
137
- """
138
- TODO docstring here
155
+ """Cretes a Vega chart element.
139
156
157
+ Parameters
158
+ ----------
159
+ data: JSON-like str or object
160
+ The Vega description of the chart.
161
+ It can also ba any object that has a method `to_json`, so that you can (for instance)
162
+ provide a `vincent` chart.
163
+ width: int or str, default None
164
+ The width of the output element.
165
+ If None, either data['width'] (if available) or '100%' will be used.
166
+ Ex: 120 , '120px', '80%'
167
+ height: int or str, default None
168
+ The height of the output element.
169
+ If None, either data['width'] (if available) or '100%' will be used.
170
+ Ex: 120 , '120px', '80%'
171
+ left: int or str, default '0%'
172
+ The horizontal distance of the output with respect to the parent HTML object.
173
+ Ex: 120 , '120px', '80%'
174
+ top: int or str, default '0%'
175
+ The vertical distance of the output with respect to the parent HTML object.
176
+ Ex: 120 , '120px', '80%'
177
+ position: str, default 'relative'
178
+ The `position` argument that the CSS shall contain.
179
+ Ex: 'relative', 'absolute'
140
180
"""
141
181
super (Vega , self ).__init__ ()
142
182
self ._name = 'Vega'
@@ -200,9 +240,7 @@ def render(self, **kwargs):
200
240
201
241
class GeoJson (Layer ):
202
242
def __init__ (self , data , style_function = None , name = None , overlay = True , control = True ):
203
- """
204
- Creates a GeoJson plugin to append into a map with
205
- Map.add_plugin.
243
+ """Creates a GeoJson object for plotting into a Map.
206
244
207
245
Parameters
208
246
----------
@@ -326,16 +364,45 @@ def _get_self_bounds(self):
326
364
class TopoJson (Layer ):
327
365
def __init__ (self , data , object_path , style_function = None ,
328
366
name = None , overlay = True , control = True ):
329
- """
330
- TODO docstring here
367
+ """Creates a TopoJson object for plotting into a Map.
331
368
369
+ Parameters
370
+ ----------
371
+ data: file, dict or str.
372
+ The TopoJSON data you want to plot.
373
+ * If file, then data will be read in the file and fully
374
+ embedded in Leaflet's JavaScript.
375
+ * If dict, then data will be converted to JSON and embedded
376
+ in the JavaScript.
377
+ * If str, then data will be passed to the JavaScript as-is.
378
+ object_path: str
379
+ The path of the desired object into the TopoJson structure.
380
+ Ex: 'objects.myobject'.
381
+ style_function: function, default None
382
+ A function mapping a TopoJson geometry to a style dict.
332
383
name : string, default None
333
384
The name of the Layer, as it will appear in LayerControls
334
385
overlay : bool, default False
335
386
Whether the layer is optional (overlay) or compulsory.
336
387
control : bool, default True
337
388
Whether the Layer will be included in LayerControls
338
389
390
+ Examples
391
+ --------
392
+ >>> # Providing file that shall be embeded.
393
+ >>> TopoJson(open('foo.json'), 'object.myobject')
394
+ >>> # Providing filename that shall not be embeded.
395
+ >>> TopoJson('foo.json', 'object.myobject')
396
+ >>> # Providing dict.
397
+ >>> TopoJson(json.load(open('foo.json')), 'object.myobject')
398
+ >>> # Providing string.
399
+ >>> TopoJson(open('foo.json').read(), 'object.myobject')
400
+
401
+ >>> # Provide a style_function that color all states green but Alabama.
402
+ >>> style_function = lambda x: {'fillColor': '#0000ff' if
403
+ ... x['properties']['name']=='Alabama' else
404
+ ... '#00ff00'}
405
+ >>> TopoJson(topo_json, 'object.myobject', style_function=style_function)
339
406
"""
340
407
super (TopoJson , self ).__init__ (name = name , overlay = overlay , control = control )
341
408
self ._name = 'TopoJson'
@@ -452,14 +519,20 @@ def render(self, **kwargs):
452
519
453
520
class MarkerCluster (Layer ):
454
521
"""Adds a MarkerCluster layer on the map."""
455
- def __init__ (self , overlay = True , control = True ):
522
+ def __init__ (self , name = None , overlay = True , control = True ):
456
523
"""Creates a MarkerCluster element to append into a map with
457
524
Map.add_children.
458
525
459
526
Parameters
460
527
----------
528
+ name : string, default None
529
+ The name of the Layer, as it will appear in LayerControls
530
+ overlay : bool, default False
531
+ Whether the layer is optional (overlay) or compulsory.
532
+ control : bool, default True
533
+ Whether the Layer will be included in LayerControls
461
534
"""
462
- super (MarkerCluster , self ).__init__ (overlay = overlay , control = control )
535
+ super (MarkerCluster , self ).__init__ (name = name , overlay = overlay , control = control )
463
536
self ._name = 'MarkerCluster'
464
537
self ._template = Template (u"""
465
538
{% macro script(this, kwargs) %}
@@ -519,7 +592,6 @@ def __init__(self, html=None, icon_size=None, icon_anchor=None,
519
592
520
593
For more information see:
521
594
http://leafletjs.com/reference.html#divicon
522
-
523
595
"""
524
596
super (DivIcon , self ).__init__ ()
525
597
self ._name = 'DivIcon'
@@ -547,9 +619,22 @@ def __init__(self, html=None, icon_size=None, icon_anchor=None,
547
619
class CircleMarker (Marker ):
548
620
def __init__ (self , location , radius = 500 , color = 'black' ,
549
621
fill_color = 'black' , fill_opacity = 0.6 , popup = None ):
550
- """
551
- TODO docstring here
622
+ """Creates a CircleMarker object for plotting on a Map.
552
623
624
+ Parameters
625
+ ----------
626
+ location: tuple or list, default None
627
+ Latitude and Longitude of Marker (Northing, Easting)
628
+ radius: int
629
+ The radius of the circle in pixels.
630
+ color: str, default 'black'
631
+ The color of the marker's edge in a HTML-compatible format.
632
+ fill_color: str, default 'black'
633
+ The fill color of the marker in a HTML-compatible format.
634
+ fill_opacity: float, default à.6
635
+ The fill opacity of the marker, between 0. and 1.
636
+ popup: string or folium.Popup, default None
637
+ Input text or visualization for object.
553
638
"""
554
639
super (CircleMarker , self ).__init__ (location , popup = popup )
555
640
self ._name = 'CircleMarker'
@@ -577,9 +662,11 @@ def __init__(self, location, radius=500, color='black',
577
662
578
663
class LatLngPopup (MacroElement ):
579
664
def __init__ (self ):
580
- """
581
- TODO docstring here
665
+ """When one clicks on a Map that contains a LatLngPopup, a popup is shown that displays
666
+ the latitude and longitude of the pointer.
582
667
668
+ Parameters
669
+ ----------
583
670
"""
584
671
super (LatLngPopup , self ).__init__ ()
585
672
self ._name = 'LatLngPopup'
@@ -601,9 +688,14 @@ def __init__(self):
601
688
602
689
class ClickForMarker (MacroElement ):
603
690
def __init__ (self , popup = None ):
604
- """
605
- TODO docstring here
691
+ """When one clicks on a Map that contains a ClickForMarker, a Marker is created
692
+ at the pointer's position.
606
693
694
+ Parameters
695
+ ----------
696
+ popup: str, default None
697
+ Text to display in the markers' popups.
698
+ If None, the popups will display the marker's latitude and longitude.
607
699
"""
608
700
super (ClickForMarker , self ).__init__ ()
609
701
self ._name = 'ClickForMarker'
0 commit comments