fitBounds returning wrong center
See original GitHub issueHey,
Fitbounds util function seems to be returning the wrong center. Here is a fiddle to reproduce our problem: https://jsfiddle.net/omerts/ndo35v4t/4/
How we call the function:
fitBounds({
nw: { lat: 34.745555, lng: 35.07048499999996 },
se: { lat:32.745555, lng: 35.07048499999996 }
},
{
width: 955, // Map width in pixels
height: 450 // Map height in pixels
}))
Actual (Invalid) result:
{ center: { lat: 33.75138591767201, lng: -144.92951500000004 }}
Expected result (taken from google’s getCenter function)
{ center: { lat: 33.745555, lng: 35.07048499999996 }}
Issue Analytics
- State:
- Created 6 years ago
- Comments:7
Top Results From Across the Web
javascript - fitBounds does not center correctly
After that I use fitBounds to fit the two markers on the map. Normally this would result in the following: Normally functioning fitBounds....
Read more >fitBounds does something strange
I'm not able to figure out the behavior of fitBounds(). Right now I have around 70 markers that I'm displaying on the map,...
Read more >map.fitBounds(map.getBounds()) zooms out map - Issue Tracker
Another solution would be that getBounds() returns the bounds inside the automatically ... first center the map at the center of the bounds...
Read more >react-google-maps/api
LatLngBounds(center); map.fitBounds(bounds); setMap(map) }, []) const onUnmount = React.useCallback(function callback(map) { setMap(null) } ...
Read more >Leaflet - map.fitBounds() / map.getBoundsZoom() BROKEN ...
Check the console output too. Or is there some a mistake in my source code? leaflet · cartography.
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
If you really want to change something just provide a PR, fork, just do anything instead of writing words
for my usecases this is enough. I see no reason to check and validate every input, I have a better ideas how to spend my time and this is not writing obvious checks