Set fitBounds only initially
See original GitHub issueI want to set initial fitBounds
when the map loads for the first time. If I do so, the map goes back to these bounds whenever data changes (it’s supposed to be a live map with moving Feature
s). That’s annoying to the user because they might be browsing the map by manually moving the view port and zooming. Whenever there’s an update, they’re back at the position computed from fitBounds
.
What’s the best way of initially setting fitBounds
but then don’t go back to these bounds on update?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Google Maps API v3 - fitBounds centers only one marker
Your code is always calling fitBounds with a LatLngBounds of only one point, the last marker... If you are calling that function several...
Read more >leaflet - how does one reset map.fitbounds (zoomtofeature ...
I guess I could set a global variable to hold the state on the first event, and do an if inside zoomToFeature to...
Read more >Setting the exact bounds of a map - Google Groups
I've got a simple map and I want to set it's exact bounds. I tried using map.fitBounds(myBounds) and map.panToBounds(myBounds), but both do not...
Read more >Map | MapLibre GL JS Docs
A Map#fitBounds options object to use only when fitting the initial bounds provided above. options.renderWorldCopies. boolean. default: true. If true , multiple ...
Read more >Map | Mapbox GL JS
A Map#fitBounds options object to use only when fitting the initial ... By default, GL JS will not set a language so that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @mastertinner , you should not break reference equality between rendering meaning you should keep the reference of the array of your fitbounds: Dont do:
Instead do:
Thanks, @alex3165! That worked perfectly.