fitBounds breaks when bounds 'nw' === 'se'
See original GitHub issuelet’s say the bounds for fitBounds is:
{ "nw": { "lat": 33.76845, "lng": -84.3883053 }, "se": { "lat": 33.76845, "lng": -84.3883053 } }
fitBounds will return
{ "zoom": 0, "center": { "lat": 33.76844999999999, "lng": 95.61169469999999 } }
Issue Analytics
- State:
- Created 7 years ago
- Reactions:10
- Comments:8
Top Results From Across the Web
Leaflet - map.fitBounds() / map.getBoundsZoom() BROKEN ...
But fitBounds seems to be broken after resizing the map. Same problem with map.getBoundsZoom(). To reproduce the buggy behaviour, start with a ...
Read more >Fit a map to a bounding box | Mapbox GL JS
This example zooms and pans the map so the new visible area of the map fits within the specified geographical bounds.
Read more >Documentation - a JavaScript library for interactive maps
Sets a map view that contains the given geographical bounds with the maximum zoom level possible. fitWorld(<fitBounds options> options?) this. Sets a map...
Read more >L.LatLngBounds
Method Returns Description
getSouthWest() LatLng Returns the south‑west point of the bounds.
getNorthEast() LatLng Returns the north‑east point of the bounds.
getNorthWest() LatLng Returns the north‑west...
Read more >map.fitBounds(map.getBounds()) zooms out map - Issue Tracker
Another solution would be that getBounds() returns the bounds inside the automatically added margins (but this could break existing applications) ...
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 Free
Top 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
@magicalbanana Sure. In the end we had a function that got the nw and se as a param and we made sure those to points weren’t identically by adding / substracting a tiny number. Here’s the complete function:
I got similar issues with
onChange
callback, the correct longitude is -121.8863286, but center return 238.11366940000005.{center: {lat: 37.33820819999998, lng: 238.11366940000005}, zoom: 16, bounds: {nw: {lat: 37.34186755251527, lng: -121.89283227465205}, se: {lat: 37.33454866918679, lng: -121.87982892534785}}, marginBounds: {nw: {lat: 37.34186755251527, lng: -121.89283227465205}, se: {lat: 37.33454866918679, lng: -121.87982892534785}}, size: {width: 606, height: 429}} 39