When one clicks on a Map that contains a LatLngPopup, a popup is shown that displays the latitude and longitude of the pointer.
| 1773 | |
| 1774 | |
| 1775 | class LatLngPopup(MacroElement): |
| 1776 | """ |
| 1777 | When one clicks on a Map that contains a LatLngPopup, |
| 1778 | a popup is shown that displays the latitude and longitude of the pointer. |
| 1779 | |
| 1780 | """ |
| 1781 | |
| 1782 | _template = Template( |
| 1783 | """ |
| 1784 | {% macro script(this, kwargs) %} |
| 1785 | var {{this.get_name()}} = L.popup(); |
| 1786 | function latLngPop(e) { |
| 1787 | {{this.get_name()}} |
| 1788 | .setLatLng(e.latlng) |
| 1789 | .setContent("Latitude: " + e.latlng.lat.toFixed(4) + |
| 1790 | "<br>Longitude: " + e.latlng.lng.toFixed(4)) |
| 1791 | .openOn({{this._parent.get_name()}}); |
| 1792 | } |
| 1793 | {{this._parent.get_name()}}.on('click', latLngPop); |
| 1794 | {% endmacro %} |
| 1795 | """ |
| 1796 | ) # noqa |
| 1797 | |
| 1798 | def __init__(self): |
| 1799 | super().__init__() |
| 1800 | self._name = "LatLngPopup" |
| 1801 | |
| 1802 | |
| 1803 | class ClickForMarker(MacroElement): |
nothing calls this directly
no test coverage detected
searching dependent graphs…