Skip to content

Add info button#135

Merged
giswqs merged 7 commits intomainfrom
info-btn
Nov 22, 2025
Merged

Add info button#135
giswqs merged 7 commits intomainfrom
info-btn

Conversation

@giswqs
Copy link
Copy Markdown
Member

@giswqs giswqs commented Nov 20, 2025

No description provided.

Copilot AI review requested due to automatic review settings November 20, 2025 05:22
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Nov 20, 2025

@github-actions github-actions Bot temporarily deployed to pull request November 20, 2025 05:23 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 an info toggle button to the MapLibre Geoman control panel, allowing users to enable/disable the info box interaction feature. The implementation includes UI controls, event handler management, and adjustments to default behavior.

  • Introduces a new InfoToggleControl class with toggle functionality and visual feedback
  • Implements DOM-level event capture to handle cases where Geoman stops event propagation
  • Changes the default value of paint_above_geoman from true to false for better layering control

Reviewed Changes

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

File Description
anymap/static/maplibre_widget.js Adds InfoToggleControl UI component, DOM capture handlers for info box events, visibility control for Geoman mirror layers, and logic to disable info mode when edit/delete tools are active
anymap/maplibre.py Updates default value of paint_above_geoman parameter from True to False

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

Comment thread anymap/static/maplibre_widget.js Outdated

// DOM capture handler (in case Geoman stops propagation)
const domEvent = (el._gmInfoMode === 'hover') ? 'mousemove' : 'click';
const domHandler = (ev) => {
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

The DOM handler duplicates the event type determination logic from lines 4850-4856. Consider extracting this into a helper function or reusing a shared constant to avoid inconsistency if the event mapping changes in the future:

const getEventName = (mode) => (mode === 'hover') ? 'mousemove' : 'click';
const domEvent = getEventName(el._gmInfoMode);

Copilot uses AI. Check for mistakes.
Comment on lines +5541 to +5542
this._button.style.boxShadow = '0 0 0 2px rgba(33,150,243,0.8) inset';
this._button.style.backgroundColor = 'rgba(33, 150, 243, 0.15)';
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

The styling values (color, box-shadow) are hardcoded here and duplicated for the active state. Consider extracting these as constants at the class level or using CSS classes instead of inline styles for better maintainability:

const ACTIVE_STYLES = {
  boxShadow: '0 0 0 2px rgba(33,150,243,0.8) inset',
  backgroundColor: 'rgba(33, 150, 243, 0.15)'
};

Copilot uses AI. Check for mistakes.
Comment thread anymap/static/maplibre_widget.js Outdated
Comment on lines +5745 to +5750
const currentEvents = model.get("_js_events") || [];
model.set("_js_events", [
...currentEvents,
{ type: 'geoman_info_toggled', enabled: false }
]);
model.save_changes();
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

This code block duplicates the event dispatching logic from lines 5587-5589. Consider extracting this into a reusable helper function to reduce code duplication:

const dispatchInfoToggleEvent = (enabled) => {
  const events = model.get("_js_events") || [];
  model.set("_js_events", [...events, { type: 'geoman_info_toggled', enabled }]);
  model.save_changes();
};

Copilot uses AI. Check for mistakes.
Comment thread anymap/static/maplibre_widget.js Outdated
giswqs and others added 3 commits November 21, 2025 22:32
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-actions github-actions Bot temporarily deployed to pull request November 22, 2025 03:34 Inactive
@github-actions github-actions Bot temporarily deployed to pull request November 22, 2025 03:52 Inactive
@github-actions github-actions Bot temporarily deployed to pull request November 22, 2025 04:04 Inactive
@github-actions github-actions Bot temporarily deployed to pull request November 22, 2025 04:28 Inactive
@giswqs giswqs merged commit 4840669 into main Nov 22, 2025
8 checks passed
@giswqs giswqs deleted the info-btn branch November 22, 2025 04:28
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