mapbox-gl-js icon indicating copy to clipboard operation
mapbox-gl-js copied to clipboard

FitBounds wrongly warns "cannot fit" and not works.

Open bewithjonam opened this issue 9 years ago • 2 comments

mapbox-gl-js version: 0.34.0 Browser: Chrome. Mac OSX. (not sure about other browsers)

Steps to Trigger Behavior

  1. https://jsfiddle.net/bewithjonam/4sb4ycb0/1/
  2. Click on the "Not Working" button

Expected Behavior

1.) The map should pan and fit to the given bounds.

Actual Behavior

1.) The map is not panning or zooming to the bounds.

map.fitBounds([[-122.33,37.90],[-122.33,37.91]]) SMALL bounds is WORKING.

map.fitBounds([[-122.23,37.84],[-122.33,37.91]]) Comparatively a little BIGGER bounds is NOT WORKING. It is warning once "Map cannot fit within canvas with the given bounds, padding, and/or offset."

bewithjonam avatar Apr 12 '17 14:04 bewithjonam

Your coordinates in the "not working" example are not correctly ordered. If you do [[-122.33,37.84],[-122.23,37.91]], it works correctly. So closing as working as intended.

mourner avatar Apr 12 '17 14:04 mourner

bewithjonam How did you calculate the coordinates to get the exact area in view?

mohsinrahman avatar May 15 '18 11:05 mohsinrahman