# Leaflet.js + OpenStreetMap Map Integration Replace SVG world maps with real interactive Leaflet.js maps using OpenStreetMap tiles. ## Setup ```html ``` ## Container div (replaces old SVG `viewBox`) ```html
``` ```css #leafletMap { width: 100%; height: 500px; border-radius: 12px; overflow: hidden; border: 1px solid rgba(14, 165, 233, 0.25); } ``` ## Dark theme overrides Apply these to match a dark mockup theme: ```css .leaflet-container { background: #0a1628; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; } .leaflet-popup-content-wrapper { background: #0f2b4a; color: #e2e8f0; border: 1px solid rgba(14, 165, 233, 0.25); border-radius: 12px; padding: 0; box-shadow: 0 4px 20px rgba(0,0,0,0.5); } .leaflet-popup-tip { background: #0f2b4a; border: 1px solid rgba(14, 165, 233, 0.25); } .leaflet-popup-content { margin: 12px 16px; font-size: 13px; line-height: 1.5; min-width: 200px; } .leaflet-popup-close-button { color: #94a3b8 !important; } .leaflet-popup-close-button:hover { color: #e2e8f0 !important; } .leaflet-control-zoom a { background: #0f2b4a !important; color: #e2e8f0 !important; border-color: rgba(14, 165, 233, 0.25) !important; } .leaflet-control-zoom a:hover { background: #1a3a5c !important; } .leaflet-control-attribution { background: rgba(10, 22, 40, 0.8) !important; color: #64748b !important; font-size: 10px !important; } .leaflet-control-attribution a { color: #0ea5e9 !important; } ``` ## Region data (real coordinates) Old SVG pattern used pixel coords + display strings. New pattern uses real lat/lng: ```js const MAP_REGIONS = [ { id: 1, name: "Florida East Coast", emoji: "🏖️", lat: 29.0, lng: -80.5 }, // ... ]; ``` ## Map initialization + markers ```js function renderMapView() { // Destroy previous instance (important for view-switching UIs) if (window._leafletMap) { window._leafletMap.remove(); window._leafletMap = null; } const map = L.map('leafletMap', { center: [20, 0], zoom: 2, maxZoom: 5, minZoom: 2, zoomControl: true, }); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors', maxNativeZoom: 5, }).addTo(map); window._leafletMap = map; MAP_REGIONS.forEach(mr => { // Color by state (available / yours / taken / waiting) const marker = L.circleMarker([mr.lat, mr.lng], { radius: 10, color: '#0ea5e9', fillColor: '#0ea5e9', fillOpacity: 0.5, opacity: 0.8, weight: 2, }).addTo(map); marker.bindPopup(`