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

LatLngBounds extend error #32

Open
jimbok8 opened this issue Feb 5, 2021 · 0 comments
Open

LatLngBounds extend error #32

jimbok8 opened this issue Feb 5, 2021 · 0 comments

Comments

@jimbok8
Copy link

jimbok8 commented Feb 5, 2021

In LatLngsBounds the extend method is used to combine the present bounds with another bounds: using this method

 public void extend(LatLngBounds bounds) {
        if (bounds != null) {
            if (northEast == null) {
                northEast = new LatLng(bounds.getNorth(), bounds.getEast());
            }
            if (southWest == null) {
                southWest = new LatLng(bounds.getSouth(), bounds.getWest());
            }
            northEast.setLat(Math.max(northEast.getLat(), bounds.getSouthWest().getLat()));
            northEast.setLng(Math.max(northEast.getLng(), bounds.getSouthWest().getLng()));
            southWest.setLat(Math.min(southWest.getLat(), bounds.getNorthEast().getLat()));
            southWest.setLng(Math.min(southWest.getLng(), bounds.getNorthEast().getLng()));
        }
    }

I think the last 4 lines are wrong and should be:

            northEast.setLat(Math.max(northEast.getLat(), bounds.getNorthEast().getLat()));
            northEast.setLng(Math.max(northEast.getLng(), bounds.getNorthEast().getLng()));
            southWest.setLat(Math.min(southWest.getLat(), bounds.getSouthWest().getLat()));
            southWest.setLng(Math.min(southWest.getLng(), bounds.getSouthWest().getLng()));
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

1 participant