mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-05-22 12:25:05 +02:00
Two issues from manual testing of the v1.32 maps bundle on NOMAD3:
1. Refresh of /maps flew to (0, 0) at zoom 12 — Gulf of Guinea / null island.
Root cause: getMapLocationParams() was reading lat/lng with Number(params.get('lat')),
but Number(null) === 0 and Number('') === 0. When URL had no params (the typical
refresh case), both lat and lng silently parsed as 0, validation passed (0 is finite
and in bounds), and handleMapLoad triggered a flyTo (0, 0, 12).
Fix: check that lat and lng params are present and non-empty before parsing.
2. User expectation: refresh should preserve current map position and zoom.
Add localStorage persistence (key 'nomad:map-view'). Save on onMoveEnd; restore
from initialViewState on mount. Priority order: URL params -> saved view -> default.
Removed now-redundant flyToLocationParams + handleMapLoad — initialViewState handles
URL params directly.
3. UX improvement: when /maps loads with ?lat=X&lng=Y, pre-fill the page's
coordinate search input with "lat,lng" so the user can immediately click the
marker button to drop a pin at that location without re-typing.
Files:
admin/inertia/components/maps/MapComponent.tsx
- getMapLocationParams: hard-fail on null/empty params (export now)
- getSavedMapView: new helper for localStorage view restore (with bounds check)
- initialViewState: lazy useState picking URL > saved > default
- onMoveEnd: persist current view to localStorage
- removed flyToLocationParams + handleMapLoad
admin/inertia/pages/maps.tsx
- import getMapLocationParams
- lazy useState pre-fills coordinateSearch from URL params
|
||
|---|---|---|
| .. | ||
| app | ||
| bin | ||
| commands | ||
| config | ||
| constants | ||
| database | ||
| docs | ||
| inertia | ||
| providers | ||
| public | ||
| resources/views | ||
| start | ||
| tests | ||
| types | ||
| util | ||
| views | ||
| .editorconfig | ||
| .env.example | ||
| ace.js | ||
| adonisrc.ts | ||
| eslint.config.js | ||
| package-lock.json | ||
| package.json | ||
| tailwind.config.ts | ||
| tsconfig.json | ||
| vite.config.ts | ||