mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
- Remove nested git repository from bugulma/frontend/.git - Add all frontend files to main repository tracking - Convert from separate frontend/backend repos to unified monorepo - Preserve all frontend code and development history as tracked files - Eliminate nested repository complexity for simpler development workflow This creates a proper monorepo structure with frontend and backend coexisting in the same repository for easier development and deployment.
6.3 KiB
6.3 KiB
Leaflet Migration Complete ✅
Summary
Successfully migrated from @vnedyalk0v/react19-simple-maps to Leaflet with react-leaflet. All legacy code has been removed.
✅ Completed Tasks
1. Installed Dependencies
- ✅
leaflet- Core mapping library - ✅
react-leaflet- React bindings for Leaflet - ✅
react-leaflet-markercluster- Marker clustering plugin - ✅
@types/leaflet- TypeScript definitions - ✅
@types/leaflet.markercluster- TypeScript definitions for clustering
2. Created New Components
- ✅
LeafletMap.tsx- Main map component using Leaflet - ✅
OrganizationMarkers.tsx- Organization markers with proper icon rendering - ✅
HistoricalMarkers.tsx- Historical landmark markers - ✅
SymbiosisLines.tsx- Connection lines between organizations - ✅
OrganizationCenterHandler.tsx- Auto-centers map on selected org - ✅
MapControls.tsx- Updated to use Leaflet map instance
3. Updated Components
- ✅
MapPicker.tsx- Migrated to Leaflet with click and drag support - ✅
MapView.tsx- Updated to useLeafletMap - ✅
useMapInteraction.ts- Fixed to work with Site coordinates - ✅
MapContexts.tsx- Updated zoom defaults and coordinate format
4. Created New Hooks
- ✅
useOrganizationSites.ts- Fetches sites for organizations in parallel
5. Fixed Critical Bugs
- ✅ Location Data Access - Now uses Sites instead of non-existent
Organization.location - ✅ Marker Positioning - Markers properly positioned using Leaflet's coordinate system
- ✅ Coordinate Format - Fixed to use
[lat, lng]format (Leaflet standard) - ✅ Icon Rendering - Properly renders React icons using
ReactDOMServer.renderToString()
6. Removed Legacy Code
- ❌ Deleted
InteractiveMap.tsx(old component) - ❌ Deleted
MapMarker.tsx(old SVG-based marker) - ❌ Deleted
AiConnectionLines.tsx(old connection lines) - ❌ Deleted
HistoricalMarker.tsx(old historical marker) - ❌ Deleted
MapDebugger.tsx(debug tool for old library) - ❌ Deleted
components/debug/README.md(debug documentation) - ❌ Deleted
scripts/test-map-config.ts(old test script) - ❌ Removed
@vnedyalk0v/react19-simple-mapsdependency - ❌ Removed
react-zoom-pan-pinchdependency (unused) - ❌ Removed
debug:mapscript from package.json - ❌ Removed
/debug/maproute from AppRouter - ❌ Removed old library references from
index.html - ❌ Removed
/debug/mapfrom e2e tests
Key Improvements
🚀 Performance
- Marker Clustering - Automatically clusters nearby markers using
react-leaflet-markercluster - Viewport Culling - Leaflet handles this automatically
- Efficient Rendering - Better performance with many markers
- Parallel Site Fetching - Uses
useQueriesto fetch all sites in parallel
🐛 Bug Fixes
- Location Data - Fixed critical bug where
org.locationdidn't exist - Marker Positioning - Markers now properly positioned using Site coordinates
- Coordinate System - Consistent
[lat, lng]format throughout - Icon Rendering - Properly renders React icons using server-side rendering
🎨 Features
- Better Popups - Native Leaflet popups with better styling
- Smooth Animations - Leaflet's built-in animations
- Touch Support - Better mobile/tablet support
- Accessibility - Better keyboard navigation
- Draggable Markers - In MapPicker for location selection
Technical Details
Icon Rendering
Icons are properly rendered using ReactDOMServer.renderToString() to convert React icon components to HTML strings that Leaflet's DivIcon can use:
const iconElement = React.cloneElement(sector.icon, {
width: size * 0.6,
height: size * 0.6,
className: 'text-primary-foreground',
style: {
width: `${size * 0.6}px`,
height: `${size * 0.6}px`,
color: 'hsl(var(--primary-foreground))',
fill: 'currentColor',
},
});
const iconHtml = renderToString(iconElement);
Site-Based Location Access
Organizations don't have direct location data. Instead, we:
- Fetch Sites for each organization using
useOrganizationSites - Create a map:
Organization ID → Site - Use Site coordinates (
Latitude,Longitude) for markers
Coordinate Format
- Leaflet Standard:
[latitude, longitude](not[lng, lat]) - All coordinates now use this format consistently
Files Changed
New Files
components/map/LeafletMap.tsxcomponents/map/OrganizationMarkers.tsxcomponents/map/HistoricalMarkers.tsxcomponents/map/SymbiosisLines.tsxcomponents/map/OrganizationCenterHandler.tsxhooks/map/useOrganizationSites.ts
Modified Files
pages/MapView.tsxcomponents/ui/MapPicker.tsxcomponents/map/MapControls.tsxhooks/map/useMapInteraction.tscontexts/MapContexts.tsxsrc/AppRouter.tsxpackage.jsonindex.htmle2e/check-links.spec.ts
Deleted Files
components/map/InteractiveMap.tsxcomponents/map/MapMarker.tsxcomponents/map/AiConnectionLines.tsxcomponents/map/HistoricalMarker.tsxcomponents/debug/MapDebugger.tsxcomponents/debug/README.mdscripts/test-map-config.ts
Dependencies
Added
{
"leaflet": "^1.9.4",
"react-leaflet": "^5.0.0",
"react-leaflet-markercluster": "^5.0.0-rc.0",
"@types/leaflet": "^1.9.21",
"@types/leaflet.markercluster": "^1.5.6"
}
Removed
{
"@vnedyalk0v/react19-simple-maps": "^1.2.0",
"react-zoom-pan-pinch": "^3.7.0"
}
Migration Benefits
- Mature Library - Leaflet is battle-tested with 10+ years of development
- Better Performance - Built-in optimizations and clustering
- Rich Ecosystem - Many plugins available
- Better Documentation - Extensive docs and community support
- Mobile Support - Excellent touch and mobile support
- Type Safety - Full TypeScript support
Next Steps
- ✅ Test the map in development
- ✅ Verify all markers appear correctly
- ✅ Test marker clustering with many organizations
- ✅ Verify connection lines work
- ✅ Test on mobile devices
- ⚠️ Monitor performance with many markers (100+)
Migration completed successfully! 🎉
The map now uses Leaflet, a mature, well-maintained library with excellent performance and features. All legacy code has been removed.