Map Component
The Map component is an interactive Leaflet-based map built with Solid.js for visualizing places on Andrew Gao’s website. It features dynamic marker rendering, popups, and responsive behavior.Location
~/workspace/source/src/components/Map.tsx
Props
Array of place objects to display on the map
Place Interface
~/workspace/source/src/lib/places.ts:10-18 for the type definition.
Features
Dynamic Marker Visibility
The map displays different marker types based on zoom level:- Zoom level ≥ 11: Pin markers (📌) with full detail
- Zoom level < 11: Small dot markers for overview
~/workspace/source/src/components/Map.tsx:35 for the MIN_ZOOM_PINS constant.
Interactive Markers
- Click marker to view details in popup/sheet
- Hover effects for better UX
- Custom icons with border and shadow
~/workspace/source/src/components/Map.tsx:74-85.
Map Configuration
- Center: NYC coordinates (40.749, -73.986)
- Bounds: Limited to Northeast US region
- Southwest: (38, -79)
- Northeast: (47, -68)
- Zoom range: 7 (min) to 20 (max)
- Tile provider: Stadia Maps (Alidade Bright style)
~/workspace/source/src/components/Map.tsx:38-62.
Popups and Sheets
When a marker is clicked:- Desktop: Shows popup near marker (planned)
- Mobile: Shows bottom sheet with place details
- Place name
- Address
- Notes (if available)
- Date added
~/workspace/source/src/components/Map.tsx:171-187 for Sheet component.
Usage Example
Basic Implementation
~/workspace/source/src/pages/places.astro:14-42 for the full implementation.
Required Stylesheets
Include Leaflet CSS in the page<head>:
State Management
The component uses Solid.js signals for reactive state:~/workspace/source/src/components/Map.tsx:32-34.
Event Handlers
onClickMarker
Triggered when a marker is clicked:~/workspace/source/src/components/Map.tsx:146-149.
onClickMap
Triggered when clicking empty map area:~/workspace/source/src/components/Map.tsx:151-153.
updateMarkerVisibility
Triggered on zoom end:~/workspace/source/src/components/Map.tsx:122-144.
Solid.js Integration
The component uses Solid.js lifecycle methods:- onMount: Initialize Leaflet map, add markers, set up event listeners
- onCleanup: Remove map instance when component unmounts
~/workspace/source/src/components/Map.tsx:37-120 and ~/workspace/source/src/components/Map.tsx:155-158.
Customizing the Map
Change Tile Provider
Replace the Stadia Maps tiles with another provider:Adjust Map Bounds
Modify the geographic constraints:Change Zoom Threshold
Modify when pins vs dots are shown:Data Sources
Places data can come from:- Notion Database: Query
NOTION_DB_ID_PLACESat build time - Google Maps: Scrape saved places using Puppeteer (see
src/lib/places.ts) - Static JSON: Load from
public/places.json
Related Components
- Layout Component - Use
main-p-0slot for full-width maps - Icon Component - Could be used for custom marker icons
Dependencies
leaflet: ^1.9.4 - Core mapping librarysolid-js: ^1.9.5 - Reactive UI frameworkdate-fns: Date formatting for timestamps