Skip to content

Add toggle_geoman_control#110

Merged
giswqs merged 1 commit intomainfrom
toggole
Nov 7, 2025
Merged

Add toggle_geoman_control#110
giswqs merged 1 commit intomainfrom
toggole

Conversation

@giswqs
Copy link
Copy Markdown
Member

@giswqs giswqs commented Nov 7, 2025

No description provided.

Copilot AI review requested due to automatic review settings November 7, 2025 23:30
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Nov 7, 2025

@github-actions github-actions Bot temporarily deployed to pull request November 7, 2025 23:31 Inactive
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds programmatic control for collapsing and expanding the Geoman drawing toolbar. The implementation includes three new Python methods and their corresponding JavaScript handlers, along with notebook examples demonstrating the functionality.

  • Adds collapse_geoman_control(), expand_geoman_control(), and toggle_geoman_control() methods to the MapLibre API
  • Implements JavaScript handlers with concurrency protection to prevent rapid successive operations
  • Updates the Geoman example notebook to demonstrate the new collapse/expand functionality

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
anymap/maplibre.py Adds three new methods for controlling Geoman toolbar collapse state
anymap/static/maplibre_widget.js Implements JavaScript handlers with concurrency control and refactors collapse state logic
docs/examples/maplibre_geoman.ipynb Adds demonstration cells for collapse/expand/toggle functionality and updates cell IDs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +29 to +46
"cell_type": "code",
"execution_count": null,
"id": "2",
"metadata": {},
"outputs": [],
"source": [
"m.expand_geoman_control()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3",
"metadata": {},
"outputs": [],
"source": [
"m.collapse_geoman_control()"
]
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These cells demonstrate expand_geoman_control() and collapse_geoman_control() without any context or explanation, immediately after creating the map. This is confusing for users following the notebook sequentially. Consider removing these early cells since the same functionality is properly documented later in the notebook (lines 169-194) with clear explanations and context.

Copilot uses AI. Check for mistakes.
}

// Track ongoing collapse/expand operations to prevent rapid successive clicks
let geomanCollapseInProgress = false;
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The global geomanCollapseInProgress flag is shared across all map instances on the same page. If multiple maps with Geoman controls exist, collapsing/expanding one map's control could prevent operations on another map's control. Consider making this flag instance-specific by storing it on the map element or geomanInstance object (e.g., el._geomanCollapseInProgress or instance._collapseInProgress).

Copilot uses AI. Check for mistakes.
@giswqs giswqs merged commit 832336d into main Nov 7, 2025
15 checks passed
@giswqs giswqs deleted the toggole branch November 7, 2025 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants