Add a measurement widget on the map. Parameters ---------- position: str, default 'topright' Location of the widget. primary_length_unit: str, default 'meters' secondary_length_unit: str, default 'miles' primary_area_unit: str, default 'sqmeters' secondary_area_u
| 6 | |
| 7 | |
| 8 | class MeasureControl(JSCSSMixin, MacroElement): |
| 9 | """Add a measurement widget on the map. |
| 10 | |
| 11 | Parameters |
| 12 | ---------- |
| 13 | position: str, default 'topright' |
| 14 | Location of the widget. |
| 15 | primary_length_unit: str, default 'meters' |
| 16 | secondary_length_unit: str, default 'miles' |
| 17 | primary_area_unit: str, default 'sqmeters' |
| 18 | secondary_area_unit: str, default 'acres' |
| 19 | |
| 20 | See https://github.com/ljagis/leaflet-measure for more information. |
| 21 | |
| 22 | """ |
| 23 | |
| 24 | _template = Template( |
| 25 | """ |
| 26 | {% macro script(this, kwargs) %} |
| 27 | var {{ this.get_name() }} = new L.Control.Measure( |
| 28 | {{ this.options|tojavascript }}); |
| 29 | {{this._parent.get_name()}}.addControl({{this.get_name()}}); |
| 30 | |
| 31 | // Workaround for using this plugin with Leaflet>=1.8.0 |
| 32 | // https://github.com/ljagis/leaflet-measure/issues/171 |
| 33 | L.Control.Measure.include({ |
| 34 | _setCaptureMarkerIcon: function () { |
| 35 | // disable autopan |
| 36 | this._captureMarker.options.autoPanOnFocus = false; |
| 37 | // default function |
| 38 | this._captureMarker.setIcon( |
| 39 | L.divIcon({ |
| 40 | iconSize: this._map.getSize().multiplyBy(2) |
| 41 | }) |
| 42 | ); |
| 43 | }, |
| 44 | }); |
| 45 | |
| 46 | {% endmacro %} |
| 47 | """ |
| 48 | ) # noqa |
| 49 | |
| 50 | default_js = [ |
| 51 | ( |
| 52 | "leaflet_measure_js", |
| 53 | "https://cdn.jsdelivr.net/gh/ljagis/leaflet-measure@2.1.7/dist/leaflet-measure.min.js", |
| 54 | ) |
| 55 | ] |
| 56 | |
| 57 | default_css = [ |
| 58 | ( |
| 59 | "leaflet_measure_css", |
| 60 | "https://cdn.jsdelivr.net/gh/ljagis/leaflet-measure@2.1.7/dist/leaflet-measure.min.css", |
| 61 | ) |
| 62 | ] |
| 63 | |
| 64 | def __init__( |
| 65 | self, |
nothing calls this directly
no test coverage detected
searching dependent graphs…