From 4f1c93b2e75d2ec21cee688b16f4722eefec3402 Mon Sep 17 00:00:00 2001 From: saheelsapovadia Date: Sun, 7 Sep 2025 16:07:27 +0000 Subject: [PATCH 1/2] documentation added for geoman plugin with example --- docs/user_guide/plugins.rst | 3 + docs/user_guide/plugins/geoman.md | 93 +++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 docs/user_guide/plugins/geoman.md diff --git a/docs/user_guide/plugins.rst b/docs/user_guide/plugins.rst index 8197f6ff20..7bfbd95bc3 100644 --- a/docs/user_guide/plugins.rst +++ b/docs/user_guide/plugins.rst @@ -13,6 +13,7 @@ Plugins plugins/float_image plugins/fullscreen plugins/geocoder + plugins/geoman plugins/grouped_layer_control plugins/heatmap plugins/heatmap_with_time @@ -65,6 +66,8 @@ Plugins - A fullscreen button control for modern browsers, using HTML Fullscreen API. * - :doc:`Geocoder ` - A clean and extensible control for both geocoding and reverse geocoding using different geocoding providers. + * - :doc:`Geoman ` + - Interactive drawing and editing interface for polygons, polylines, circles, and other geometric shapes. * - :doc:`Grouped Layer Control ` - Create layer control with support for grouping overlays together. * - :doc:`Heatmap ` diff --git a/docs/user_guide/plugins/geoman.md b/docs/user_guide/plugins/geoman.md new file mode 100644 index 0000000000..f06ef3c8b4 --- /dev/null +++ b/docs/user_guide/plugins/geoman.md @@ -0,0 +1,93 @@ +# Geoman + +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. + +## Basic Usage + +```{code-cell} ipython3 +import folium +from folium.plugins import GeoMan + +# Create a map +m = folium.Map(location=[45.5236, -122.6750], zoom_start=13) + +# Add Geoman plugin +GeoMan().add_to(m) + +m +``` + +## Customizing Controls + +You can customize which drawing controls are available and their position: + +```{code-cell} ipython3 +import folium +from folium.plugins import GeoMan + +m = folium.Map(location=[45.5236, -122.6750], zoom_start=13) + +# Add Geoman with custom options +GeoMan( + position='topright', + drawMarker=True, + drawCircleMarker=True, + drawPolyline=True, + drawRectangle=True, + drawPolygon=True, + drawCircle=True, + drawText=False, + editMode=True, + dragMode=True, + cutPolygon=True, + removalMode=True, + rotateMode=False +).add_to(m) + +m +``` + +## Available Methods + +The GeoMan plugin provides several methods for programmatic control: + +### Drawing Controls +- `enable_draw(shape, **kwargs)`: Enable drawing mode for a specific shape +- `disable_draw()`: Disable drawing mode +- `set_path_options(**options)`: Set default styling options for drawn shapes + +### Edit Controls +- `enable_global_edit_mode(**options)`: Enable edit mode for all shapes +- `disable_global_edit_mode()`: Disable edit mode +- `enable_global_drag_mode()`: Enable drag mode for all shapes +- `disable_global_drag_mode()`: Disable drag mode + +### Other Controls +- `enable_global_removal_mode()`: Enable removal mode +- `disable_global_removal_mode()`: Disable removal mode +- `enable_global_cut_mode()`: Enable polygon cutting mode +- `disable_global_cut_mode()`: Disable polygon cutting mode +- `enable_global_rotation_mode()`: Enable rotation mode +- `disable_global_rotation_mode()`: Disable rotation mode + +## Configuration Options + +The GeoMan plugin accepts the following parameters: + +- `position` (str): Position of the toolbar ('topleft', 'topright', 'bottomleft', 'bottomright') +- `feature_group` (FeatureGroup): Feature group to store drawn items +- `on` (dict): Event handlers for drawing events +- `drawMarker` (bool): Enable/disable marker drawing +- `drawCircleMarker` (bool): Enable/disable circle marker drawing +- `drawPolyline` (bool): Enable/disable polyline drawing +- `drawRectangle` (bool): Enable/disable rectangle drawing +- `drawPolygon` (bool): Enable/disable polygon drawing +- `drawCircle` (bool): Enable/disable circle drawing +- `drawText` (bool): Enable/disable text drawing +- `editMode` (bool): Enable/disable edit mode +- `dragMode` (bool): Enable/disable drag mode +- `cutPolygon` (bool): Enable/disable polygon cutting +- `removalMode` (bool): Enable/disable removal mode +- `rotateMode` (bool): Enable/disable rotation mode + +For more advanced usage and configuration options, refer to the [Leaflet-Geoman documentation](https://geoman.io/docs/leaflet). From bae2a1f009ae8f04514e31af97a3b4782f72a7ea Mon Sep 17 00:00:00 2001 From: saheelsapovadia Date: Sun, 7 Sep 2025 17:51:58 +0000 Subject: [PATCH 2/2] documentation updated --- docs/user_guide/plugins/geoman.md | 51 +++++-------------------------- 1 file changed, 8 insertions(+), 43 deletions(-) diff --git a/docs/user_guide/plugins/geoman.md b/docs/user_guide/plugins/geoman.md index f06ef3c8b4..4fe14f7d47 100644 --- a/docs/user_guide/plugins/geoman.md +++ b/docs/user_guide/plugins/geoman.md @@ -2,6 +2,14 @@ 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. +## Advantages over Draw Plugin + +Geoman is a more recent and actively maintained alternative to the Draw plugin, offering several key advantages: + +- **Advanced Shape Features**: Supports drawing shapes with holes inside them, which is not available in the Draw plugin +- **Enhanced Editing Capabilities**: Includes cutting, rotating, scaling, and snapping functionality for precise geometry editing +- **Professional Add-ons**: Offers [paid extensions](https://geoman.io/docs/leaflet/getting-started/pro-version) with advanced functionality for complex GIS applications + ## Basic Usage ```{code-cell} ipython3 @@ -47,47 +55,4 @@ GeoMan( m ``` -## Available Methods - -The GeoMan plugin provides several methods for programmatic control: - -### Drawing Controls -- `enable_draw(shape, **kwargs)`: Enable drawing mode for a specific shape -- `disable_draw()`: Disable drawing mode -- `set_path_options(**options)`: Set default styling options for drawn shapes - -### Edit Controls -- `enable_global_edit_mode(**options)`: Enable edit mode for all shapes -- `disable_global_edit_mode()`: Disable edit mode -- `enable_global_drag_mode()`: Enable drag mode for all shapes -- `disable_global_drag_mode()`: Disable drag mode - -### Other Controls -- `enable_global_removal_mode()`: Enable removal mode -- `disable_global_removal_mode()`: Disable removal mode -- `enable_global_cut_mode()`: Enable polygon cutting mode -- `disable_global_cut_mode()`: Disable polygon cutting mode -- `enable_global_rotation_mode()`: Enable rotation mode -- `disable_global_rotation_mode()`: Disable rotation mode - -## Configuration Options - -The GeoMan plugin accepts the following parameters: - -- `position` (str): Position of the toolbar ('topleft', 'topright', 'bottomleft', 'bottomright') -- `feature_group` (FeatureGroup): Feature group to store drawn items -- `on` (dict): Event handlers for drawing events -- `drawMarker` (bool): Enable/disable marker drawing -- `drawCircleMarker` (bool): Enable/disable circle marker drawing -- `drawPolyline` (bool): Enable/disable polyline drawing -- `drawRectangle` (bool): Enable/disable rectangle drawing -- `drawPolygon` (bool): Enable/disable polygon drawing -- `drawCircle` (bool): Enable/disable circle drawing -- `drawText` (bool): Enable/disable text drawing -- `editMode` (bool): Enable/disable edit mode -- `dragMode` (bool): Enable/disable drag mode -- `cutPolygon` (bool): Enable/disable polygon cutting -- `removalMode` (bool): Enable/disable removal mode -- `rotateMode` (bool): Enable/disable rotation mode - For more advanced usage and configuration options, refer to the [Leaflet-Geoman documentation](https://geoman.io/docs/leaflet).