MCPcopy Create free account
hub / github.com/python-visualization/folium / FastMarkerCluster

Class FastMarkerCluster

folium/plugins/fast_marker_cluster.py:6–107  ·  view source on GitHub ↗

Add marker clusters to a map using in-browser rendering. Using FastMarkerCluster it is possible to render 000's of points far quicker than the MarkerCluster class. Be aware that the FastMarkerCluster class passes an empty list to the parent class' __init__ method during initial

Source from the content-addressed store, hash-verified

4
5
6class FastMarkerCluster(MarkerCluster):
7 """
8 Add marker clusters to a map using in-browser rendering.
9 Using FastMarkerCluster it is possible to render 000's of
10 points far quicker than the MarkerCluster class.
11
12 Be aware that the FastMarkerCluster class passes an empty
13 list to the parent class' __init__ method during initialisation.
14 This means that the add_child method is never called, and
15 no reference to any marker data are retained. Methods such
16 as get_bounds() are therefore not available when using it.
17
18 Parameters
19 ----------
20 data: list of list with values
21 List of list of shape [[lat, lon], [lat, lon], etc.]
22 When you use a custom callback you could add more values after the
23 lat and lon. E.g. [[lat, lon, 'red'], [lat, lon, 'blue']]
24 callback: string, optional
25 A string representation of a valid Javascript function
26 that will be passed each row in data. See the
27 FasterMarkerCluster for an example of a custom callback.
28 name : string, optional
29 The name of the Layer, as it will appear in LayerControls.
30 overlay : bool, default True
31 Adds the layer as an optional overlay (True) or the base layer (False).
32 control : bool, default True
33 Whether the Layer will be included in LayerControls.
34 show: bool, default True
35 Whether the layer will be shown on opening.
36 icon_create_function : string, default None
37 Override the default behaviour, making possible to customize
38 markers colors and sizes.
39 **kwargs
40 Additional arguments are passed to Leaflet.markercluster options. See
41 https://github.com/Leaflet/Leaflet.markercluster
42
43 """
44
45 _template = Template(
46 """
47 {% macro script(this, kwargs) %}
48 var {{ this.get_name() }} = (function(){
49 {{ this.callback }}
50
51 var data = {{ this.data|tojson }};
52 var cluster = L.markerClusterGroup({{ this.options|tojavascript }});
53 {%- if this.icon_create_function is not none %}
54 cluster.options.iconCreateFunction =
55 {{ this.icon_create_function.strip() }};
56 {%- endif %}
57
58 for (var i = 0; i < data.length; i++) {
59 var row = data[i];
60 var marker = callback(row);
61 marker.addTo(cluster);
62 }
63

Callers 2

test_fast_marker_clusterFunction · 0.90

Calls 1

TemplateClass · 0.90

Tested by 2

test_fast_marker_clusterFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…