Appearance
UC-029.4: Map Engine โ Custom POIs & Waypoints โ
๐ 1. Context & Problem Statement โ
- Interactive Spatial Markers: Standard GPX route files contain POIs (Water, Food, viewpoints, campsites). Users need to drop custom points directly onto the map canvas during route planning or review to highlight locations.
- Database Alignment & Tenant Isolation: POIs must be persisted to the database, tied to the requesting user via secure foreign keys, and protected against unauthorized deletions from other users.
โ๏ธ 2. Backend Logic & API (apps/api) โ
- Database schema: Implemented
poistable withid,userId(references users.id, cascade delete),routeId(references routes.id, nullable, cascade delete),typeenum (WATER,FOOD,HAZARD,VIEWPOINT,CAMPING,GENERAL),name(varchar),coordinates(jsonb tuple[lng, lat]), anddescription(text). - Secure Router Factory:
GET /api/poisfetching only POIs belonging to the activeuserId, supporting dynamic Bounding Box (bbox) filtering.POST /api/poisvalidating coordinate formats (object vs tuple) and type boundaries.PATCH /api/pois/:idenforcing ownership checks and updating details.DELETE /api/pois/:idverifying the requesting user owns the POI, rejecting foreign deletions with403 Forbidden.
๐จ 3. User Interface (apps/web) โ
- Context Menu Option: Right-clicking an empty map space displays a floating absolute HTML menu featuring
[ ๐ Add POI ]which captures map coordinates and opens the modal form. - Glassmorphic Create Form: Renders inputs for Name, Category grid select buttons, and Descriptions. Custom categories map to distinct Catppuccin mocha brand SVG icons (Water ๐ง, Food ๐, Hazards โ ๏ธ, Camp โบ, Viewpoint ๐ญ, and General ๐).
- MapLibre Interactive Markers: Markers render custom brand-colored SVGs and support optimistic drag-and-drop movements that update the backend and local stores with automatic error rollbacks.
- Popup Details & Confirmation: Clicking a marker opens a MapLibre Popup containing descriptions and a double-click confirm delete gate.
๐งช 4. Testing Requirements โ
- Integration Tests: Verify tenant isolation during deletes. Verify bbox search filtering.
- Frontend Tests: Verify validation errors on empty name inputs, type chip switches, and modal closes.