nismod / irv-jamaica

Jamaica Systemic Resilience Assessment Tool
MIT License
0 stars 0 forks source link

URL parameters for map location, layer selection #7

Open tomalrussell opened 4 months ago

tomalrussell commented 4 months ago

Also nice-to-have to port over:

See https://github.com/nismod/irv-frontend/pull/20

eatyourgreens commented 1 month ago

Currently implemented:

Example URL, with infrastructure, hazards, and buildings visible: https://jamaica.infrastructureresilience.org/exposure?lat=17.87511&lon=-77.24007&zoom=12.78&assets=true&hazards=true&buildings=true&regions=false&terrestrial=false&marine=false

eatyourgreens commented 1 month ago

A couple more PRs:

Map sidebar state is shareable now, but the URLs are ~5k characters.

eatyourgreens commented 1 month ago

Some work on shortening URLs by removing redundant query parameters (mostly optimising tree state by writing a list of visible asset layer IDs to the URL.)

eatyourgreens commented 1 month ago

I've run into a weird problem where urlSyncEffect works fine in local development, then doesn't work at all in a production build. It can be worked around by adding a Recoil state effect that updates the window history, but that's annoying.

I'm wondering if this is a side effect of the update to React 18. Recoil seems to be abandoned now, so it wouldn't surprise me if it has bugs with the latest React.