Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reversing lngLat in fitBounds #83

Closed
daviestar opened this issue May 17, 2016 · 1 comment
Closed

Reversing lngLat in fitBounds #83

daviestar opened this issue May 17, 2016 · 1 comment

Comments

@daviestar
Copy link

daviestar commented May 17, 2016

Is there a reason why you are accepting latLng bounds instead of lngLat bounds in fitBounds? https://github.com/uber/react-map-gl/blob/es6/src/fit-bounds.js#L28

I am confused as to why its breaking the convention of lngLat coordinates.

My use case:

function extent(markers) {
  let extent = [[-Infinity, -Infinity], [Infinity, Infinity]];
  for(let lngLat of markers) {
    if(lngLat[0] > extent[0][0]) {
      extent[0][0] = lngLat[0];
    } else if(lngLat[0] < extent[1][0]) {
      extent[1][0] = lngLat[0];
    }

    if(lngLat[1] > extent[0][1]) {
      extent[0][1] = lngLat[1];
    } else if(lngLat[1] < extent[1][1]) {
      extent[1][1] = lngLat[1];
    }
  }

  // https://github.com/uber/react-map-gl/issues/83
  extent = [extent[0].reverse(), extent[1].reverse()];

  return extent;
};

const MAP_ONLOAD = MapGL.fitBounds(width, height, extent(store.markers), {padding: 50});

Thanks

@ibgreen
Copy link
Contributor

ibgreen commented Aug 26, 2016

@daviestar Good point. We are going to make a new version of fitBounds that supports perspective mode, we will fix this in the new API and deprecate this method. Given that a new method is coming, for backwards compatibility I prefer not to change the current method.

@ibgreen ibgreen closed this as completed Aug 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants