MCPcopy Index your code
hub / github.com/python-visualization/folium / MousePosition

Class MousePosition

folium/plugins/mouse_position.py:8–101  ·  view source on GitHub ↗

Add a field that shows the coordinates of the mouse position. Uses the Leaflet plugin by Ardhi Lukianto under MIT license. https://github.com/ardhi/Leaflet.MousePosition Parameters ---------- position : str, default 'bottomright' The standard Control position parameter

Source from the content-addressed store, hash-verified

6
7
8class MousePosition(JSCSSMixin, MacroElement):
9 """Add a field that shows the coordinates of the mouse position.
10
11 Uses the Leaflet plugin by Ardhi Lukianto under MIT license.
12 https://github.com/ardhi/Leaflet.MousePosition
13
14 Parameters
15 ----------
16 position : str, default 'bottomright'
17 The standard Control position parameter for the widget.
18 separator : str, default ' : '
19 Character used to separate latitude and longitude values.
20 empty_string : str, default 'Unavailable'
21 Initial text to display.
22 lng_first : bool, default False
23 Whether to put the longitude first or not.
24 Set as True to display longitude before latitude.
25 num_digits : int, default '5'
26 Number of decimal places included in the displayed
27 longitude and latitude decimal degree values.
28 prefix : str, default ''
29 A string to be prepended to the coordinates.
30 lat_formatter : str, default None
31 Custom Javascript function to format the latitude value.
32 lng_formatter : str, default None
33 Custom Javascript function to format the longitude value.
34
35 Examples
36 --------
37 >>> fmtr = "function(num) {return L.Util.formatNum(num, 3) + ' º ';};"
38 >>> MousePosition(
39 ... position="topright",
40 ... separator=" | ",
41 ... prefix="Mouse:",
42 ... lat_formatter=fmtr,
43 ... lng_formatter=fmtr,
44 ... )
45
46 """
47
48 _template = Template(
49 """
50 {% macro script(this, kwargs) %}
51 var {{ this.get_name() }} = new L.Control.MousePosition(
52 {{ this.options|tojavascript }}
53 );
54 {{ this.get_name() }}.options["latFormatter"] =
55 {{ this.lat_formatter }};
56 {{ this.get_name() }}.options["lngFormatter"] =
57 {{ this.lng_formatter }};
58 {{ this._parent.get_name() }}.addControl({{ this.get_name() }});
59 {% endmacro %}
60 """
61 )
62
63 default_js = [
64 (
65 "Control_MousePosition_js",

Callers 1

Calls 1

TemplateClass · 0.90

Tested by

no test coverage detected