Search in sources :

Example 1 with CameraOptions

use of com.mapbox.maps.CameraOptions 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)

Example 2 with CameraOptions

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

the class RCTMGLSnapshotModule method getCameraOptions.

private CameraOptions getCameraOptions(ReadableMap jsOptions) {
    Feature centerPoint = Feature.fromJson(jsOptions.getString("centerCoordinate"));
    Point point = (Point) centerPoint.geometry();
    CameraOptions.Builder cameraOptionsBuilder = new CameraOptions.Builder();
    CameraOptions cameraOptions = cameraOptionsBuilder.center(point).pitch(jsOptions.getDouble("pitch")).bearing(jsOptions.getDouble("heading")).zoom(jsOptions.getDouble("zoomLevel")).build();
    return cameraOptions;
}
Also used : CameraOptions(com.mapbox.maps.CameraOptions) Point(com.mapbox.geojson.Point) Feature(com.mapbox.geojson.Feature)

Aggregations

CameraOptions (com.mapbox.maps.CameraOptions)2 Feature (com.mapbox.geojson.Feature)1 Point (com.mapbox.geojson.Point)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