Skip to content

Enable snapping by default#108

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

Enable snapping by default#108
giswqs merged 1 commit intomainfrom
snapping

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 15:19
@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 15:20 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 enables snapping by default in the Geoman draw control and updates the documentation to reflect this change. Snapping helps users create precise geometries by snapping to existing features when drawing on the map.

  • Enables snapping by default in the add_geoman_control method
  • Updates the Jupyter notebook example to document the default snapping behavior and show how to disable it
  • Removes commented-out configuration example and replaces it with a clearer custom configuration section

Reviewed Changes

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

File Description
anymap/maplibre.py Adds logic to enable snapping by default in the Geoman control configuration
docs/examples/maplibre_geoman.ipynb Documents the new snapping default behavior and provides an example of how to disable it
Comments suppressed due to low confidence (1)

anymap/maplibre.py:1752

  • The snapping default is set before user-provided controls are processed, but the controls parameter uses .update() which can override nested values. If a user passes controls={\"helper\": {\"snapping\": {}}}, the empty dict will override the default {\"active\": True}, resulting in snapping being disabled when it should be enabled by default. Consider checking for the active key after merging user controls, or use a deep merge strategy that preserves the default when not explicitly overridden.
        # Enable snapping by default
        geoman_controls = geoman_config.setdefault("controls", {})
        helper_controls = geoman_controls.setdefault("helper", {})
        snapping_config = helper_controls.setdefault("snapping", {})
        if "active" not in snapping_config:
            snapping_config["active"] = True

        if controls:
            for section, section_options in controls.items():
                if isinstance(section_options, dict):
                    section_config = geoman_controls.setdefault(section, {})
                    section_config.update(section_options)

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

@giswqs giswqs merged commit e137289 into main Nov 7, 2025
14 checks passed
@giswqs giswqs deleted the snapping branch November 7, 2025 15:30
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