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

Class LocateControl

folium/plugins/locate_control.py:13–77  ·  view source on GitHub ↗

Control plugin to geolocate the user. This plugins adds a button to the map, and when it's clicked shows the current user device location. To work properly in production, the connection needs to be encrypted, otherwise browser will not allow users to share their location. Para

Source from the content-addressed store, hash-verified

11
12
13class LocateControl(JSCSSMixin, MacroElement):
14 """Control plugin to geolocate the user.
15
16 This plugins adds a button to the map, and when it's clicked shows the current
17 user device location.
18
19 To work properly in production, the connection needs to be encrypted, otherwise browser will not
20 allow users to share their location.
21
22 Parameters
23 ----------
24 auto-start : bool, default False
25 When set to True, plugin will be activated on map loading and search for user position.
26 Once user location is founded, the map will automatically centered in using user coordinates.
27 **kwargs
28 For possible options, see https://github.com/domoritz/leaflet-locatecontrol
29
30 Examples
31 --------
32 >>> m = folium.Map()
33 # With default settings
34 >>> LocateControl().add_to(m)
35
36 # With some custom options
37 >>> LocateControl(
38 ... position="bottomright",
39 ... strings={"title": "See you current location", "popup": "Your position"},
40 ... ).add_to(m)
41
42 For more info check:
43 https://github.com/domoritz/leaflet-locatecontrol
44
45 """
46
47 _template = Template(
48 """
49 {% macro script(this, kwargs) %}
50 var {{this.get_name()}} = L.control.locate(
51 {{this.options | tojson}}
52 ).addTo({{this._parent.get_name()}});
53 {% if this.auto_start %}
54 {{this.get_name()}}.start();
55 {% endif %}
56 {% endmacro %}
57 """
58 )
59
60 default_js = [
61 (
62 "Control_locate_min_js",
63 "https://cdnjs.cloudflare.com/ajax/libs/leaflet-locatecontrol/0.66.2/L.Control.Locate.min.js",
64 )
65 ]
66 default_css = [
67 (
68 "Control_locate_min_css",
69 "https://cdnjs.cloudflare.com/ajax/libs/leaflet-locatecontrol/0.66.2/L.Control.Locate.min.css",
70 )

Callers

nothing calls this directly

Calls 1

TemplateClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…