👋 Polyline, AntPath & EditControl Improvements 🐜🏷️ #287
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add AntPath, Street Labels, and Enhanced EditControl Features
Overview
This PR introduces three major enhancements to dash-leaflet:
I've been a long-time user of dash-leaflet and wanted to contribute features that expand its visualization capabilities while maintaining the library's ease of use.
Features Added
1. AntPath Component 🐜
A new component that creates animated polylines with a "marching ants" effect, based on leaflet-ant-path.
Features:
Example Usage:
2. Street Labels 🏷️
Curved text labels that follow the path of Polyline and AntPath components, rebuilt based on Leaflet.streetlabels.
Features:
Example Usage:
3. Enhanced EditControl 🎨
The EditControl now supports dynamic styling with custom colors for shapes and emoji icons for markers.
Features:
Example Usage:
Implementation Details
Street Labels Architecture
CanvasTextLayer: Custom Leaflet layer for rendering text on canvas
TextPathRenderer: Handles curved text rendering along paths
LabelCollisionManager: RBush-based spatial indexing for collision detection
StreetLabelContext: React context for managing label registration
Performance Optimizations
Canvas-based rendering for street labels
Request animation frame batching for updates
Delta updates for label rendering (only redraw changed labels)
Efficient collision detection using spatial indexing
Known Issues
Street Labels Dragging: Labels may temporarily follow the map drag before snapping back to position. This is a rendering synchronization issue that needs investigation.
Build Warning: Minor TypeScript warning in MousePosition component (included fix in PR)
Testing
Added example usage files:
tests/components/ant_path.py - Basic AntPath demonstration
tests/components/ant_path_advanced.py - More advanced
tests/components/dynamic_street_labels.py - change line color and text dynamically
tests/components/edit_control_simple.py - Enhanced EditControl with color/emoji picker
tests/components/edit_control_styled.py - EditControl testing in a clean dmc style
tests/components/popup_advanced.py - Exploring the use of popups
tests/components/popup_line.py - Exploring the popup on line click
tests/components/street_labels_usage.py - Basic StreetLabels
Breaking Changes
None. All changes are additive and maintain backward compatibility.
Future Enhancements
Checklist
Code follows project style guidelines
Tests added for new components
Documentation added for new features
No breaking changes to existing API
Changelog updated
Dependencies Added
leaflet-ant-path: For animated polyline functionality
rbush: For efficient collision detection
cheap-ruler: For geographic calculations