Vector drawing and editing plugin for Leaflet. Parameters ---------- export : bool, default False Add a small button that exports the drawn shapes as a geojson file. feature_group : FeatureGroup, optional The FeatureGroup object that will hold the editable figur
| 5 | |
| 6 | |
| 7 | class Draw(JSCSSMixin, MacroElement): |
| 8 | ''' |
| 9 | Vector drawing and editing plugin for Leaflet. |
| 10 | |
| 11 | Parameters |
| 12 | ---------- |
| 13 | export : bool, default False |
| 14 | Add a small button that exports the drawn shapes as a geojson file. |
| 15 | feature_group : FeatureGroup, optional |
| 16 | The FeatureGroup object that will hold the editable figures. This can |
| 17 | be used to initialize the Draw plugin with predefined Layer objects. |
| 18 | filename : string, default 'data.geojson' |
| 19 | Name of geojson file |
| 20 | position : {'topleft', 'toprigth', 'bottomleft', 'bottomright'} |
| 21 | Position of control. |
| 22 | See https://leafletjs.com/reference.html#control |
| 23 | show_geometry_on_click : bool, default True |
| 24 | When True, opens an alert with the geometry description on click. |
| 25 | draw_options : dict, optional |
| 26 | The options used to configure the draw toolbar. See |
| 27 | http://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html#drawoptions |
| 28 | edit_options : dict, optional |
| 29 | The options used to configure the edit toolbar. See |
| 30 | https://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html#editpolyoptions |
| 31 | on : dict, optional |
| 32 | Event handlers to attach to the created layer. Pass a mapping from the |
| 33 | names of the events to their `JsCode` handlers. |
| 34 | |
| 35 | Examples |
| 36 | -------- |
| 37 | >>> m = folium.Map() |
| 38 | >>> Draw( |
| 39 | ... export=True, |
| 40 | ... filename="my_data.geojson", |
| 41 | ... show_geometry_on_click=False, |
| 42 | ... position="topleft", |
| 43 | ... draw_options={"polyline": {"allowIntersection": False}}, |
| 44 | ... edit_options={"poly": {"allowIntersection": False}}, |
| 45 | ... on={ |
| 46 | ... "click": JsCode( |
| 47 | ... """ |
| 48 | ... function(event) { |
| 49 | ... alert(JSON.stringify(this.toGeoJSON())); |
| 50 | ... } |
| 51 | ... """ |
| 52 | ... ) |
| 53 | ... }, |
| 54 | ... ).add_to(m) |
| 55 | |
| 56 | For more info please check |
| 57 | https://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html |
| 58 | |
| 59 | ''' |
| 60 | |
| 61 | _template = Template( |
| 62 | """ |
| 63 | {% macro html(this, kwargs) %} |
| 64 | {% if this.export %} |
nothing calls this directly
no test coverage detected
searching dependent graphs…