Search in sources :

Example 1 with CoordinateBounds

use of com.mapbox.maps.CoordinateBounds in project maps by rnmapbox.

the class RCTMGLCamera method getUserLocationUpdateCameraOptions.

private CameraOptions getUserLocationUpdateCameraOptions(double zoomLevel) {
    LatLng center = mUserLocation.getCoordinate();
    ScreenCoordinate anchor = CameraAnimationsUtils.getCamera(mMapView).getAnchor();
    CameraState actState = mMapView.getMapboxMap().getCameraState();
    if (mUserLocationVerticalAlignment != UserLocationVerticalAlignment.CENTER) {
        CameraOptions options = ExtensionUtils.toCameraOptions(actState, anchor);
        CoordinateBounds bounds = mMapView.getMapboxMap().coordinateBoundsForCamera(options);
        switch(mUserLocationVerticalAlignment) {
            case UserLocationVerticalAlignment.TOP:
                center = new LatLng(bounds.getNortheast().latitude(), center.getLongitude());
                break;
            case UserLocationVerticalAlignment.BOTTOM:
                center = new LatLng(bounds.getSouthwest().latitude(), center.getLongitude());
                break;
        }
    }
    return new CameraOptions.Builder().center(center.getPoint()).bearing(getDirectionForUserLocationUpdate()).pitch(mPitch).anchor(anchor).padding(actState.getPadding()).zoom(zoomLevel).build();
}
Also used : CameraState(com.mapbox.maps.CameraState) ScreenCoordinate(com.mapbox.maps.ScreenCoordinate) CameraOptions(com.mapbox.maps.CameraOptions) LatLng(com.mapbox.rctmgl.utils.LatLng) CoordinateBounds(com.mapbox.maps.CoordinateBounds)

Aggregations

CameraOptions (com.mapbox.maps.CameraOptions)1 CameraState (com.mapbox.maps.CameraState)1 CoordinateBounds (com.mapbox.maps.CoordinateBounds)1 ScreenCoordinate (com.mapbox.maps.ScreenCoordinate)1 LatLng (com.mapbox.rctmgl.utils.LatLng)1