How to get LatLngBounds of visible region in title

2019-06-05 06:42发布

问题:

I tried the following code.

    LatLngBounds b = googleMap.getProjection()
                              .getVisibleRegion().latLngBounds;
    LatLng bNE = b.northeast;
    LatLng bSW = b.southwest;

It's not giving correct bounding coordinates if tilt is set to the map

回答1:

As mentioned in the Google Maps API doc VisibleRegion, the visible region for a map's camera can be in the form of a rectangle in case the camera is centered over the map region which will give you correct bounding coordinates. While it can also be in the form of a trapezoid, in case the camera has tilt, which is your case.

That's why you're getting wrong bounding coordinates!