hasadna / open-bus-map-search

open-bus-map-search
https://open-bus-map-search.hasadna.org.il/dashboard
MIT License
51 stars 90 forks source link

style: center map automatically when data changes #729

Closed itsoriki closed 5 months ago

itsoriki commented 5 months ago

Description

Resolve #726

github-actions[bot] commented 5 months ago

Preview: https://s3.amazonaws.com/noam-gaash.co.il/8939114019/open-bus/b031d8ab4a5536460e50287874c9964f66661ac5/index.html Preview Storybook: https://s3.amazonaws.com/noam-gaash.co.il/8939114019/open-bus/b031d8ab4a5536460e50287874c9964f66661ac5/storybook/index.html

itsoriki commented 5 months ago

You're correct - the thing is this useEffect needs to sit inside the map context in order for the setView to work properly - For that we must use one of our own components, i.e. the MapIndex component or introduce a new one with a clear name and a single purpose being the centering mechanism (like I tried to do here...).

What do you think @NoamGaash ?

itsoriki commented 5 months ago

Check out the error being thrown when I try to do as you suggest: image

NoamGaash commented 5 months ago

I see. Have you tried editing center={position.loc}?