-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce leaflet-geoman as an alternative to leaflet-draw (#1181)
* feat: move from leaflet-draw to leaflet-geoman * refactor: improved backwards compatibility * docs: document GeomanDrawControl * implement fixes to issues found in review * refactor: retain old DrawControl for migration period * update reference images * incorporate suggestions from review * Apply suggestions from code review Co-authored-by: Maarten Breddels <[email protected]> * fix: correct default options previously `circlemarker` incorrectly defaulted to using `markerStyle`, while it isn't a leaflet marker layer. Moreover, polyline and polygon would use the old (`shapeOptions`) by default even with geoman, where it should be `pathOptions`. This was fixed by the compatibility layer, but this way the defaults are clearer. --------- Co-authored-by: Maarten Breddels <[email protected]>
- Loading branch information
1 parent
4a732d0
commit 8a96abe
Showing
12 changed files
with
3,449 additions
and
2,320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
Geoman Draw Control | ||
============ | ||
|
||
``GeomanDrawControl`` allows one to draw various shapes on the map. | ||
The drawing functionality on the front-end is provided by `geoman <https://geoman.io/>`_. | ||
|
||
The following shapes are supported: | ||
- marker | ||
- circlemarker | ||
- circle | ||
- polyline | ||
- rectangle | ||
- polygon | ||
- text | ||
|
||
Additionally, there are modes that allow editing of previously drawn shapes: | ||
|
||
- edit | ||
- drag | ||
- remove | ||
- cut | ||
- rotate | ||
|
||
To have a drawing tool active on the map, pass it a non-empty dictionary with the desired options, see | ||
`geoman documentation <https://www.geoman.io/docs/modes/draw-mode#customize-style>`_ for details. | ||
|
||
Example | ||
------- | ||
.. jupyter-execute:: | ||
|
||
from ipyleaflet import Map, GeomanDrawControl | ||
|
||
m = Map(center=(50, 354), zoom=5) | ||
|
||
draw_control = GeomanDrawControl() | ||
draw_control.polyline = { | ||
"pathOptions": { | ||
"color": "#6bc2e5", | ||
"weight": 8, | ||
"opacity": 1.0 | ||
} | ||
} | ||
draw_control.polygon = { | ||
"pathOptions": { | ||
"fillColor": "#6be5c3", | ||
"color": "#6be5c3", | ||
"fillOpacity": 1.0 | ||
} | ||
} | ||
draw_control.circlemarker = { | ||
"pathOptions": { | ||
"fillColor": "#efed69", | ||
"color": "#efed69", | ||
"fillOpacity": 0.62 | ||
} | ||
} | ||
draw_control.rectangle = { | ||
"pathOptions": { | ||
"fillColor": "#fca45d", | ||
"color": "#fca45d", | ||
"fillOpacity": 1.0 | ||
} | ||
} | ||
|
||
m.add(draw_control) | ||
|
||
m | ||
|
||
Methods | ||
------- | ||
|
||
.. autoclass:: ipyleaflet.leaflet.GeomanDrawControl | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.