Skip to content

Commit 87c101e

Browse files
authored
Merge pull request #678 from ocefpaf/consistent_docstring_plugins
Consistent docstring for the plugins
2 parents 4604355 + eba0e59 commit 87c101e

16 files changed

Lines changed: 319 additions & 435 deletions

folium/plugins/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
Folium plugins
55
--------------
66
7-
Add different objects/effects on a folium map.
7+
Wrap some of the most populat leaflet external plugins.
8+
89
"""
910

1011
from __future__ import (absolute_import, division, print_function)

folium/plugins/boat_marker.py

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
# -*- coding: utf-8 -*-
22

3-
"""
4-
Boat marker
5-
-----------
6-
7-
Creates a marker shaped like a boat.
8-
Optionally you can append a wind direction.
9-
10-
"""
11-
123
from __future__ import (absolute_import, division, print_function)
134

145
import json
@@ -21,28 +12,29 @@
2112

2213

2314
class BoatMarker(Marker):
24-
"""Adds a BoatMarker layer on the map."""
25-
def __init__(self, location, popup=None, icon=None,
26-
heading=0, wind_heading=None, wind_speed=0, **kwargs):
27-
"""Creates a BoatMarker plugin to append into a map with
28-
Map.add_plugin.
15+
"""
16+
Creates a BoatMarker plugin to append into a map with
17+
Map.add_plugin.
18+
19+
Parameters
20+
----------
21+
location: tuple of length 2, default None
22+
The latitude and longitude of the marker.
23+
If None, then the middle of the map is used.
2924
30-
Parameters
31-
----------
32-
location: tuple of length 2, default None
33-
The latitude and longitude of the marker.
34-
If None, then the middle of the map is used.
25+
heading: int, default 0
26+
Heading of the boat to an angle value between 0 and 360 degrees
3527
36-
heading: int, default 0
37-
Heading of the boat to an angle value between 0 and 360 degrees
28+
wind_heading: int, default None
29+
Heading of the wind to an angle value between 0 and 360 degrees
30+
If None, then no wind is represented.
3831
39-
wind_heading: int, default None
40-
Heading of the wind to an angle value between 0 and 360 degrees
41-
If None, then no wind is represented.
32+
wind_speed: int, default 0
33+
Speed of the wind in knots.
4234
43-
wind_speed: int, default 0
44-
Speed of the wind in knots.
45-
"""
35+
"""
36+
def __init__(self, location, popup=None, icon=None,
37+
heading=0, wind_heading=None, wind_speed=0, **kwargs):
4638
super(BoatMarker, self).__init__(location, popup=popup, icon=icon)
4739
self._name = 'BoatMarker'
4840
self.heading = heading

folium/plugins/fast_marker_cluster.py

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
# -*- coding: utf-8 -*-
22

3-
"""
4-
Marker Cluster plugin
5-
---------------------
6-
7-
Creates a MarkerCluster plugin to add on a folium map.
8-
"""
9-
103
from __future__ import (absolute_import, division, print_function)
114

125
from folium.plugins.marker_cluster import MarkerCluster
@@ -15,30 +8,30 @@
158

169

1710
class FastMarkerCluster(MarkerCluster):
18-
"""Add marker clusters to a map using in-browser rendering"""
11+
"""
12+
Add marker clusters to a map using in-browser rendering.
13+
Using FastMarkerCluster it is possible to render 000's of
14+
points far quicker than the MarkerCluster class.
15+
16+
Be aware that the FastMarkerCluster class passes an empty
17+
list to the parent class' __init__ method during initialisation.
18+
This means that the add_child method is never called, and
19+
no reference to any marker data are retained. Methods such
20+
as get_bounds() are therefore not available when using it.
21+
22+
Parameters
23+
----------
24+
data: list
25+
List of list of shape [[], []]. Data points should be of
26+
the form [[lat, lng]].
27+
28+
callback: string, default None
29+
A string representation of a valid Javascript function
30+
that will be passed a lat, lon coordinate pair. See the
31+
FasterMarkerCluster for an example of a custom callback.
32+
33+
"""
1934
def __init__(self, data, callback=None):
20-
"""Add marker clusters to a map using in-browser rendering.
21-
Using FastMarkerCluster it is possible to render 000's of
22-
points far quicker than the MarkerCluster class.
23-
24-
Be aware that the FastMarkerCluster class passes an empty
25-
list to the parent class' __init__ method during initialisation.
26-
This means that the add_child method is never called, and
27-
no reference to any marker data are retained. Methods such
28-
as get_bounds() are therefore not available when using it.
29-
30-
Parameters
31-
----------
32-
data: list
33-
List of list of shape [[], []]. Data points should be of
34-
the form [[lat, lng]].
35-
36-
callback: string, default None
37-
A string representation of a valid Javascript function
38-
that will be passed a lat, lon coordinate pair. See the
39-
FasterMarkerCluster for an example of a custom callback.
40-
41-
"""
4235
super(FastMarkerCluster, self).__init__([])
4336
self._name = 'FastMarkerCluster'
4437
self._data = data

folium/plugins/float_image.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
# -*- coding: utf-8 -*-
22

3-
"""
4-
FloatImage plugin
5-
-----------------
6-
7-
Adds a floating image in HTML canvas on top of the map.
8-
"""
9-
103
from __future__ import (absolute_import, division, print_function)
114

125
from branca.element import MacroElement
@@ -15,8 +8,8 @@
158

169

1710
class FloatImage(MacroElement):
11+
"""Adds a floating image in HTML canvas on top of the map."""
1812
def __init__(self, image, bottom=75, left=75):
19-
"""Adds a floating image in HTML canvas on top of the map."""
2013
super(FloatImage, self).__init__()
2114
self._name = 'FloatImage'
2215
self.image = image

folium/plugins/fullscreen.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
# -*- coding: utf-8 -*-
22

3-
"""
4-
Fullscreen
5-
--------------
6-
7-
https://github.com/brunob/leaflet.fullscreen
8-
9-
Adds fullscreen button to your maps.
10-
"""
11-
123
from __future__ import (absolute_import, division, print_function)
134

145
from branca.element import CssLink, Figure, JavascriptLink, MacroElement
@@ -29,31 +20,31 @@ class Fullscreen(MacroElement):
2920
title : str
3021
change the title of the button,
3122
default: 'Full Screen'
32-
titleCancel : str
23+
title_cancel : str
3324
change the title of the button when fullscreen is on,
3425
default: 'Exit Full Screen'
35-
forceSeparateButton : boolean
26+
force_separate_button : boolean
3627
force seperate button to detach from zoom buttons,
3728
default: False
38-
"""
29+
See https://github.com/brunob/leaflet.fullscreen for more information.
3930
31+
"""
4032
def __init__(self, position='topleft', title='Full Screen',
41-
titleCancel='Exit Full Screen', forceSeparateButton=False):
42-
"""Add button to take your Folium map fullscreen"""
33+
title_cancel='Exit Full Screen', force_separate_button=False):
4334
super(Fullscreen, self).__init__()
4435
self._name = 'Fullscreen'
4536
self.position = position
4637
self.title = title
47-
self.titleCancel = titleCancel
48-
self.forceSeparateButton = str(forceSeparateButton).lower()
38+
self.title_cancel = title_cancel
39+
self.force_separate_button = str(force_separate_button).lower()
4940

5041
self._template = Template("""
5142
{% macro script(this, kwargs) %}
5243
L.control.fullscreen({
5344
position: '{{this.position}}',
5445
title: '{{this.title}}',
55-
titleCancel: '{{this.titleCancel}}',
56-
forceSeparateButton: {{this.forceSeparateButton}},
46+
titleCancel: '{{this.title_cancel}}',
47+
forceSeparateButton: {{this.force_separate_button}},
5748
}).addTo({{this._parent.get_name()}});
5849
{{this._parent.get_name()}}.on('enterFullscreen', function(){
5950
console.log('entered fullscreen');

folium/plugins/heat_map.py

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
# -*- coding: utf-8 -*-
22

3-
"""
4-
Heat map
5-
--------
6-
7-
Create a HeatMap layer
8-
9-
"""
10-
113
from __future__ import (absolute_import, division, print_function)
124

135
import json
@@ -21,31 +13,33 @@
2113

2214

2315
class HeatMap(TileLayer):
16+
"""
17+
Create a Heatmap layer
18+
19+
Parameters
20+
----------
21+
data : list of points of the form [lat, lng] or [lat, lng, weight]
22+
The points you want to plot.
23+
You can also provide a numpy.array of shape (n,2) or (n,3).
24+
name : str
25+
The name of the layer that will be created.
26+
min_opacity : default 1.
27+
The minimum opacity the heat will start at.
28+
max_zoom : default 18
29+
Zoom level where the points reach maximum intensity (as intensity
30+
scales with zoom), equals maxZoom of the map by default
31+
max_val : float, default 1.
32+
Maximum point intensity
33+
radius : int, default 25
34+
Radius of each "point" of the heatmap
35+
blur : int, default 15
36+
Amount of blur
37+
gradient : dict, default None
38+
Color gradient config. e.g. {0.4: 'blue', 0.65: 'lime', 1: 'red'}
39+
40+
"""
2441
def __init__(self, data, name=None, min_opacity=0.5, max_zoom=18,
2542
max_val=1.0, radius=25, blur=15, gradient=None, overlay=True):
26-
"""Create a Heatmap layer
27-
28-
Parameters
29-
----------
30-
data : list of points of the form [lat, lng] or [lat, lng, weight]
31-
The points you want to plot.
32-
You can also provide a numpy.array of shape (n,2) or (n,3).
33-
name : str
34-
The name of the layer that will be created.
35-
min_opacity : default 1.
36-
The minimum opacity the heat will start at.
37-
max_zoom : default 18
38-
Zoom level where the points reach maximum intensity (as intensity
39-
scales with zoom), equals maxZoom of the map by default
40-
max_val : float, default 1.
41-
Maximum point intensity
42-
radius : int, default 25
43-
Radius of each "point" of the heatmap
44-
blur : int, default 15
45-
Amount of blur
46-
gradient : dict, default None
47-
Color gradient config. e.g. {0.4: 'blue', 0.65: 'lime', 1: 'red'}
48-
"""
4943
super(TileLayer, self).__init__(name=name)
5044
self._name = 'HeatMap'
5145
self.tile_name = name if name is not None else self.get_name()

0 commit comments

Comments
 (0)