Conversation
|
🚀 Deployed on https://69213bdac4efd2f175504b43--opengeos.netlify.app |
There was a problem hiding this comment.
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
InfoToggleControlclass 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_geomanfromtruetofalsefor 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.
|
|
||
| // DOM capture handler (in case Geoman stops propagation) | ||
| const domEvent = (el._gmInfoMode === 'hover') ? 'mousemove' : 'click'; | ||
| const domHandler = (ev) => { |
There was a problem hiding this comment.
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);| 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)'; |
There was a problem hiding this comment.
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)'
};| const currentEvents = model.get("_js_events") || []; | ||
| model.set("_js_events", [ | ||
| ...currentEvents, | ||
| { type: 'geoman_info_toggled', enabled: false } | ||
| ]); | ||
| model.save_changes(); |
There was a problem hiding this comment.
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();
};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>
No description provided.