fix zoom on single station #210
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The GBFS validator visualizer kept zooming on a station when the passed GBFS feed only contained 1 station.
closes: #133
Reason:
This was caused by the fact that the
mapInstance.fitBounds(bboxPolygon(geojson))didn't behave as expected when called with just one data point, as the function will fit the view to the given area. If the passed parameter has an area of 0 (it's a single point) it'll continue to zoom indefinitely.I created an utility function
fitBoundsForGeojsonto address this issue and fly to the specific station in case it's one. It will also be used for the vehicles and geofencing layer as well, as they'd also be subject to the same issue.Feed used for testing: https://data.lime.bike/api/partners/v2/gbfs/opfikon/gbfs.json
Before:
Screen.Recording.2025-11-20.at.7.25.28.PM.mov
After:
Screen.Recording.2025-11-20.at.7.24.50.PM.mov