Creates a SideBySideLayers that takes two Layers and adds a sliding control with the leaflet-side-by-side plugin. Uses the Leaflet leaflet-side-by-side plugin https://github.com/digidem/leaflet-side-by-side Parameters ---------- layer_left: Layer. The left Layer wi
| 5 | |
| 6 | |
| 7 | class SideBySideLayers(JSCSSMixin, MacroElement): |
| 8 | """ |
| 9 | Creates a SideBySideLayers that takes two Layers and adds a sliding |
| 10 | control with the leaflet-side-by-side plugin. |
| 11 | |
| 12 | Uses the Leaflet leaflet-side-by-side plugin https://github.com/digidem/leaflet-side-by-side |
| 13 | |
| 14 | Parameters |
| 15 | ---------- |
| 16 | layer_left: Layer. |
| 17 | The left Layer within the side by side control. |
| 18 | Must be created and added to the map before being passed to this class. |
| 19 | layer_right: Layer. |
| 20 | The right Layer within the side by side control. |
| 21 | Must be created and added to the map before being passed to this class. |
| 22 | |
| 23 | Examples |
| 24 | -------- |
| 25 | >>> sidebyside = SideBySideLayers(layer_left, layer_right) |
| 26 | >>> sidebyside.add_to(m) |
| 27 | """ |
| 28 | |
| 29 | _template = Template( |
| 30 | """ |
| 31 | {% macro script(this, kwargs) %} |
| 32 | var {{ this.get_name() }} = L.control.sideBySide( |
| 33 | {{ this.layer_left.get_name() }}, {{ this.layer_right.get_name() }} |
| 34 | ).addTo({{ this._parent.get_name() }}); |
| 35 | {% endmacro %} |
| 36 | """ |
| 37 | ) |
| 38 | |
| 39 | default_js = [ |
| 40 | ( |
| 41 | "leaflet.sidebyside", |
| 42 | "https://cdn.jsdelivr.net/gh/digidem/leaflet-side-by-side@2.0.0/leaflet-side-by-side.min.js", |
| 43 | ), |
| 44 | ] |
| 45 | |
| 46 | def __init__(self, layer_left, layer_right): |
| 47 | super().__init__() |
| 48 | self._name = "SideBySideLayers" |
| 49 | self.layer_left = layer_left |
| 50 | self.layer_right = layer_right |
nothing calls this directly
no test coverage detected
searching dependent graphs…