question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fitBounds returning wrong center

See original GitHub issue

Hey,

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:closed
  • Created 6 years ago
  • Comments:7

github_iconTop GitHub Comments

8reactions
istarkovcommented, Sep 25, 2017

If you really want to change something just provide a PR, fork, just do anything instead of writing words

8reactions
istarkovcommented, Sep 25, 2017

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found