Skip to content

Commit 4f1c93b

Browse files
documentation added for geoman plugin with example
1 parent 60bc0d6 commit 4f1c93b

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed

docs/user_guide/plugins.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Plugins
1313
plugins/float_image
1414
plugins/fullscreen
1515
plugins/geocoder
16+
plugins/geoman
1617
plugins/grouped_layer_control
1718
plugins/heatmap
1819
plugins/heatmap_with_time
@@ -65,6 +66,8 @@ Plugins
6566
- A fullscreen button control for modern browsers, using HTML Fullscreen API.
6667
* - :doc:`Geocoder <plugins/geocoder>`
6768
- A clean and extensible control for both geocoding and reverse geocoding using different geocoding providers.
69+
* - :doc:`Geoman <plugins/geoman>`
70+
- Interactive drawing and editing interface for polygons, polylines, circles, and other geometric shapes.
6871
* - :doc:`Grouped Layer Control <plugins/grouped_layer_control>`
6972
- Create layer control with support for grouping overlays together.
7073
* - :doc:`Heatmap <plugins/heatmap>`

docs/user_guide/plugins/geoman.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Geoman
2+
3+
The Geoman plugin provides an interactive drawing and editing interface for polygons, polylines, circles, and other geometric shapes on your Folium map. It's based on the [Leaflet-Geoman](https://github.com/geoman-io/leaflet-geoman/) library.
4+
5+
## Basic Usage
6+
7+
```{code-cell} ipython3
8+
import folium
9+
from folium.plugins import GeoMan
10+
11+
# Create a map
12+
m = folium.Map(location=[45.5236, -122.6750], zoom_start=13)
13+
14+
# Add Geoman plugin
15+
GeoMan().add_to(m)
16+
17+
m
18+
```
19+
20+
## Customizing Controls
21+
22+
You can customize which drawing controls are available and their position:
23+
24+
```{code-cell} ipython3
25+
import folium
26+
from folium.plugins import GeoMan
27+
28+
m = folium.Map(location=[45.5236, -122.6750], zoom_start=13)
29+
30+
# Add Geoman with custom options
31+
GeoMan(
32+
position='topright',
33+
drawMarker=True,
34+
drawCircleMarker=True,
35+
drawPolyline=True,
36+
drawRectangle=True,
37+
drawPolygon=True,
38+
drawCircle=True,
39+
drawText=False,
40+
editMode=True,
41+
dragMode=True,
42+
cutPolygon=True,
43+
removalMode=True,
44+
rotateMode=False
45+
).add_to(m)
46+
47+
m
48+
```
49+
50+
## Available Methods
51+
52+
The GeoMan plugin provides several methods for programmatic control:
53+
54+
### Drawing Controls
55+
- `enable_draw(shape, **kwargs)`: Enable drawing mode for a specific shape
56+
- `disable_draw()`: Disable drawing mode
57+
- `set_path_options(**options)`: Set default styling options for drawn shapes
58+
59+
### Edit Controls
60+
- `enable_global_edit_mode(**options)`: Enable edit mode for all shapes
61+
- `disable_global_edit_mode()`: Disable edit mode
62+
- `enable_global_drag_mode()`: Enable drag mode for all shapes
63+
- `disable_global_drag_mode()`: Disable drag mode
64+
65+
### Other Controls
66+
- `enable_global_removal_mode()`: Enable removal mode
67+
- `disable_global_removal_mode()`: Disable removal mode
68+
- `enable_global_cut_mode()`: Enable polygon cutting mode
69+
- `disable_global_cut_mode()`: Disable polygon cutting mode
70+
- `enable_global_rotation_mode()`: Enable rotation mode
71+
- `disable_global_rotation_mode()`: Disable rotation mode
72+
73+
## Configuration Options
74+
75+
The GeoMan plugin accepts the following parameters:
76+
77+
- `position` (str): Position of the toolbar ('topleft', 'topright', 'bottomleft', 'bottomright')
78+
- `feature_group` (FeatureGroup): Feature group to store drawn items
79+
- `on` (dict): Event handlers for drawing events
80+
- `drawMarker` (bool): Enable/disable marker drawing
81+
- `drawCircleMarker` (bool): Enable/disable circle marker drawing
82+
- `drawPolyline` (bool): Enable/disable polyline drawing
83+
- `drawRectangle` (bool): Enable/disable rectangle drawing
84+
- `drawPolygon` (bool): Enable/disable polygon drawing
85+
- `drawCircle` (bool): Enable/disable circle drawing
86+
- `drawText` (bool): Enable/disable text drawing
87+
- `editMode` (bool): Enable/disable edit mode
88+
- `dragMode` (bool): Enable/disable drag mode
89+
- `cutPolygon` (bool): Enable/disable polygon cutting
90+
- `removalMode` (bool): Enable/disable removal mode
91+
- `rotateMode` (bool): Enable/disable rotation mode
92+
93+
For more advanced usage and configuration options, refer to the [Leaflet-Geoman documentation](https://geoman.io/docs/leaflet).

0 commit comments

Comments
 (0)