1919
2020
2121class 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).
2726
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
2846 """
2947 super (WmsTileLayer , self ).__init__ (overlay = overlay , control = control )
3048 self ._name = 'WmsTileLayer'
@@ -134,9 +152,31 @@ def render(self, **kwargs):
134152class Vega (Element ):
135153 def __init__ (self , data , width = None , height = None ,
136154 left = "0%" , top = "0%" , position = 'relative' ):
137- """
138- TODO docstring here
155+ """Cretes a Vega chart element.
139156
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'
140180 """
141181 super (Vega , self ).__init__ ()
142182 self ._name = 'Vega'
@@ -200,9 +240,7 @@ def render(self, **kwargs):
200240
201241class GeoJson (Layer ):
202242 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.
206244
207245 Parameters
208246 ----------
@@ -326,16 +364,45 @@ def _get_self_bounds(self):
326364class TopoJson (Layer ):
327365 def __init__ (self , data , object_path , style_function = None ,
328366 name = None , overlay = True , control = True ):
329- """
330- TODO docstring here
367+ """Creates a TopoJson object for plotting into a Map.
331368
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.
332383 name : string, default None
333384 The name of the Layer, as it will appear in LayerControls
334385 overlay : bool, default False
335386 Whether the layer is optional (overlay) or compulsory.
336387 control : bool, default True
337388 Whether the Layer will be included in LayerControls
338389
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)
339406 """
340407 super (TopoJson , self ).__init__ (name = name , overlay = overlay , control = control )
341408 self ._name = 'TopoJson'
@@ -452,14 +519,20 @@ def render(self, **kwargs):
452519
453520class MarkerCluster (Layer ):
454521 """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 ):
456523 """Creates a MarkerCluster element to append into a map with
457524 Map.add_children.
458525
459526 Parameters
460527 ----------
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
461534 """
462- super (MarkerCluster , self ).__init__ (overlay = overlay , control = control )
535+ super (MarkerCluster , self ).__init__ (name = name , overlay = overlay , control = control )
463536 self ._name = 'MarkerCluster'
464537 self ._template = Template (u"""
465538 {% macro script(this, kwargs) %}
@@ -519,7 +592,6 @@ def __init__(self, html=None, icon_size=None, icon_anchor=None,
519592
520593 For more information see:
521594 http://leafletjs.com/reference.html#divicon
522-
523595 """
524596 super (DivIcon , self ).__init__ ()
525597 self ._name = 'DivIcon'
@@ -547,9 +619,22 @@ def __init__(self, html=None, icon_size=None, icon_anchor=None,
547619class CircleMarker (Marker ):
548620 def __init__ (self , location , radius = 500 , color = 'black' ,
549621 fill_color = 'black' , fill_opacity = 0.6 , popup = None ):
550- """
551- TODO docstring here
622+ """Creates a CircleMarker object for plotting on a Map.
552623
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.
553638 """
554639 super (CircleMarker , self ).__init__ (location , popup = popup )
555640 self ._name = 'CircleMarker'
@@ -577,9 +662,11 @@ def __init__(self, location, radius=500, color='black',
577662
578663class LatLngPopup (MacroElement ):
579664 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.
582667
668+ Parameters
669+ ----------
583670 """
584671 super (LatLngPopup , self ).__init__ ()
585672 self ._name = 'LatLngPopup'
@@ -601,9 +688,14 @@ def __init__(self):
601688
602689class ClickForMarker (MacroElement ):
603690 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.
606693
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.
607699 """
608700 super (ClickForMarker , self ).__init__ ()
609701 self ._name = 'ClickForMarker'
0 commit comments