Create a FeatureGroup layer ; you can put things in it and handle them as a single layer. For example, you can add a LayerControl to tick/untick the whole group. Parameters ---------- name : str, default None The name of the featureGroup layer. It will be d
| 138 | |
| 139 | |
| 140 | class FeatureGroup(Layer): |
| 141 | """ |
| 142 | Create a FeatureGroup layer ; you can put things in it and handle them |
| 143 | as a single layer. For example, you can add a LayerControl to |
| 144 | tick/untick the whole group. |
| 145 | |
| 146 | Parameters |
| 147 | ---------- |
| 148 | name : str, default None |
| 149 | The name of the featureGroup layer. |
| 150 | It will be displayed in the LayerControl. |
| 151 | If None get_name() will be called to get the technical (ugly) name. |
| 152 | overlay : bool, default True |
| 153 | Whether your layer will be an overlay (ticked with a check box in |
| 154 | LayerControls) or a base layer (ticked with a radio button). |
| 155 | control: bool, default True |
| 156 | Whether the layer will be included in LayerControls. |
| 157 | show: bool, default True |
| 158 | Whether the layer will be shown on opening. |
| 159 | **kwargs |
| 160 | Additional (possibly inherited) options. See |
| 161 | https://leafletjs.com/reference.html#featuregroup |
| 162 | |
| 163 | """ |
| 164 | |
| 165 | _template = Template( |
| 166 | """ |
| 167 | {% macro script(this, kwargs) %} |
| 168 | var {{ this.get_name() }} = L.featureGroup( |
| 169 | {{ this.options|tojavascript }} |
| 170 | ); |
| 171 | {% endmacro %} |
| 172 | """ |
| 173 | ) |
| 174 | |
| 175 | def __init__( |
| 176 | self, |
| 177 | name: Optional[str] = None, |
| 178 | overlay: bool = True, |
| 179 | control: bool = True, |
| 180 | show: bool = True, |
| 181 | **kwargs: TypeJsonValue, |
| 182 | ): |
| 183 | super().__init__(name=name, overlay=overlay, control=control, show=show) |
| 184 | self._name = "FeatureGroup" |
| 185 | self.tile_name = name if name is not None else self.get_name() |
| 186 | self.options = remove_empty(**kwargs) |
| 187 | |
| 188 | |
| 189 | class LayerControl(MacroElement): |