gbfs-validator icon indicating copy to clipboard operation
gbfs-validator copied to clipboard

fix zoom on single station

Open SinthTeck opened this issue 3 weeks ago • 1 comments

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 fitBoundsForGeojson to 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:

https://github.com/user-attachments/assets/f329b431-0a36-46b3-b8f5-c500c594c0be

After:

https://github.com/user-attachments/assets/21e8f140-ff4f-4ff3-ba55-109a3a09557a

SinthTeck avatar Nov 21 '25 03:11 SinthTeck

Deploy request for gbfs-validator pending review.

Visit the deploys page to approve it

Name Link
Latest commit 3fbb60447e6b2c596a69315b6e33bde49c967d2b

netlify[bot] avatar Nov 21 '25 03:11 netlify[bot]

@davidgamez @Alessandro100 created this PR to solve #133, please have a look when you get the chance. Thank you!

SinthTeck avatar Nov 28 '25 19:11 SinthTeck