-
-
Notifications
You must be signed in to change notification settings - Fork 306
fix: restrict zooming and panning on the data inspector (#2325) #2326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: restrict zooming and panning on the data inspector (#2325) #2326
Conversation
- Fetch TileJSON when inspector dialog opens - Extract bounds, minzoom, maxzoom, and center from TileJSON - Configure map with initialViewState and restrictions - Apply bounds restrictions to prevent panning outside dataset extent - Set min/max zoom limits based on TileJSON data - Fit map to bounds when available, otherwise use center - Update tests to mock TileJSON fetch calls
3881bfa to
45c5c58
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
I tested the code and the first case (a raster layer) works.
The second case however (a vector map) does not seem to work nicely:
You can reproduce this by running:
VITE_MARTIN_BASE=https://nav.tum.de/martin npm run dev
and then visting http://localhost:3001/?inspect=shortbread&tab=tiles
| onLoad={() => { | ||
| // Configure bounds for raster sources after map loads | ||
| if (tileJSON) { | ||
| configureMapBounds(); | ||
| } | ||
| }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You always seem to configure this twice:
- once in the react component
- once in the onLoad callback
Could you explain this? 🤔
Seems a bit strange
| fetch(buildMartinUrl(`/${name}`)) | ||
| .then((response) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if this is very react-y.
I think the current recomendation is to use <Suspense + asyncData and just wrap the components where we need the data.
At least this is explained like this here:
What do you think? 🤔
Description
Fixes issue #2325 by restricting zooming and panning in the data inspector to the dataset's extent.
Currently, the inspector shows 0/0/0 (zoom level 0/0/0) which works for global datasets but not for local/smaller datasets. This PR implements zoom and pan restrictions based on TileJSON metadata.
Changes
/{source_ids}bounds,minzoom,maxzoom, andcenterinitialViewStateusing center coordinates if availableminZoomandmaxZoomrestrictionsmaxBoundsto prevent panning outside the dataset extentfitBounds()to automatically fit the map to the dataset bounds when availableTechnical Details
The implementation:
initialViewState,minZoom,maxZoom,maxBounds) and direct map API calls (setMinZoom,setMaxZoom,setMaxBounds,fitBounds)Testing
Screenshots
Before: Inspector showed blank map with no restrictions (0/0/0)
After: Inspector restricts zoom/pan to dataset bounds and fits to extent
Related Issues
Closes #2325