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

feat: adding back bounds #2015

Merged
merged 6 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,27 +125,13 @@ public CameraUpdateItem toCameraUpdate(RCTMGLMapView mapView) {
mBounds.toBounds(),
convert(cameraPaddingClipped),
bearing,
mTilt
tilt
);
if (boundsCamera != null) {
builder.center(boundsCamera.getCenter());
builder.anchor(boundsCamera.getAnchor());
builder.zoom(boundsCamera.getZoom());
builder.padding(boundsCamera.getPadding());
} else {
/*
CameraUpdate update = CameraUpdateFactory.newLatLngBounds(
mBounds,
cameraPaddingClipped[0],
cameraPaddingClipped[1],
cameraPaddingClipped[2],
cameraPaddingClipped[3]
);*/
CameraOptions update =
map.cameraForCoordinateBounds(mBounds.toBounds(),convert(cameraPaddingClipped),null, null);
;
return new CameraUpdateItem(map, update, mDuration, mCallback, mMode);
}

builder.center(boundsCamera.getCenter());
builder.anchor(boundsCamera.getAnchor());
builder.zoom(boundsCamera.getZoom());
builder.padding(boundsCamera.getPadding());
}

if (mZoom != null) {
Expand Down Expand Up @@ -180,10 +166,10 @@ public static CameraStop fromReadableMap(Context context, @NonNull ReadableMap r
}

if (readableMap.hasKey("bounds")) {
int paddingTop = getBoundsPaddingByKey(readableMap, "boundsPaddingTop");
Andarius marked this conversation as resolved.
Show resolved Hide resolved
int paddingRight = getBoundsPaddingByKey(readableMap, "boundsPaddingRight");
int paddingBottom = getBoundsPaddingByKey(readableMap, "boundsPaddingBottom");
int paddingLeft = getBoundsPaddingByKey(readableMap, "boundsPaddingLeft");
int paddingTop = getBoundsPaddingByKey(readableMap, "paddingTop");
int paddingRight = getBoundsPaddingByKey(readableMap, "paddingRight");
int paddingBottom = getBoundsPaddingByKey(readableMap, "paddingBottom");
int paddingLeft = getBoundsPaddingByKey(readableMap, "paddingLeft");

// scale padding by pixel ratio
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
Expand All @@ -193,9 +179,8 @@ public static CameraStop fromReadableMap(Context context, @NonNull ReadableMap r
paddingLeft = Float.valueOf(paddingLeft * metrics.scaledDensity).intValue();

FeatureCollection collection = FeatureCollection.fromJson(readableMap.getString("bounds"));
/* v10todo
stop.setBounds(GeoJSONUtils.toLatLngBounds(collection), paddingLeft, paddingRight,
paddingTop, paddingBottom); */
paddingTop, paddingBottom);
}

if (readableMap.hasKey("mode")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import com.mapbox.rctmgl.events.constants.EventKeys
import com.mapbox.maps.MapboxMap
import com.facebook.react.bridge.UiThreadUtil
import com.facebook.react.common.MapBuilder
import com.mapbox.maps.plugin.compass.compass
import com.mapbox.maps.plugin.gestures.gestures
import com.mapbox.maps.plugin.logo.logo
import com.mapbox.rctmgl.utils.ConvertUtils
import com.mapbox.rctmgl.utils.ExpressionParser
import com.mapbox.rctmgl.utils.GeoJSONUtils
Expand Down Expand Up @@ -94,23 +97,25 @@ open class RCTMGLMapViewManager(context: ReactApplicationContext?) :
}

@ReactProp(name = "zoomEnabled")
fun setZoomEnabled(mapView: RCTMGLMapView?, zoomEnabled: Boolean) {
//mapView.setReactZoomEnabled(zoomEnabled);
fun setZoomEnabled(mapView: RCTMGLMapView, zoomEnabled: Boolean) {
mapView.gestures.pinchToZoomEnabled = zoomEnabled
mapView.gestures.doubleTouchToZoomOutEnabled = zoomEnabled
mapView.gestures.doubleTapToZoomInEnabled = zoomEnabled
}

@ReactProp(name = "scrollEnabled")
fun setScrollEnabled(mapView: RCTMGLMapView?, scrollEnabled: Boolean) {
//mapView.setReactScrollEnabled(scrollEnabled);
fun setScrollEnabled(mapView: RCTMGLMapView, scrollEnabled: Boolean) {
mapView.gestures.scrollEnabled = scrollEnabled
}

@ReactProp(name = "pitchEnabled")
fun setPitchEnabled(mapView: RCTMGLMapView?, pitchEnabled: Boolean) {
//mapView.setReactPitchEnabled(pitchEnabled);
fun setPitchEnabled(mapView: RCTMGLMapView, pitchEnabled: Boolean) {
mapView.gestures.pitchEnabled = pitchEnabled
}

@ReactProp(name = "rotateEnabled")
fun setRotateEnabled(mapView: RCTMGLMapView?, rotateEnabled: Boolean) {
//mapView.setReactRotateEnabled(rotateEnabled);
fun setRotateEnabled(mapView: RCTMGLMapView, rotateEnabled: Boolean) {
mapView.gestures.rotateEnabled = rotateEnabled
}

@ReactProp(name = "attributionEnabled")
Expand All @@ -124,8 +129,8 @@ open class RCTMGLMapViewManager(context: ReactApplicationContext?) :
}

@ReactProp(name = "logoEnabled")
fun setLogoEnabled(mapView: RCTMGLMapView?, logoEnabled: Boolean) {
//mapView.setReactLogoEnabled(logoEnabled);
fun setLogoEnabled(mapView: RCTMGLMapView, logoEnabled: Boolean) {
mapView.logo.enabled = logoEnabled
}

@ReactProp(name = "logoPosition")
Expand All @@ -134,7 +139,8 @@ open class RCTMGLMapViewManager(context: ReactApplicationContext?) :
}

@ReactProp(name = "compassEnabled")
fun setCompassEnabled(mapView: RCTMGLMapView?, compassEnabled: Boolean) {
fun setCompassEnabled(mapView: RCTMGLMapView, compassEnabled: Boolean) {
mapView.compass.enabled = compassEnabled
//mapView.setReactCompassEnabled(compassEnabled);
}

Expand Down
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ export interface MapViewProps extends ViewProps {
export interface CameraProps extends CameraSettings, ViewProps {
allowUpdates?: boolean;
animationDuration?: number;
animationMode?: 'flyTo' | 'easeTo' | 'linearTo' | 'moveTo';
animationMode?: 'flyTo' | 'easeTo' | 'linearTo' | 'moveTo' | 'none';
defaultSettings?: CameraSettings;
minZoomLevel?: number;
maxZoomLevel?: number;
Expand Down
1 change: 1 addition & 0 deletions javascript/components/Camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ class Camera extends React.Component {
case Camera.Mode.Linear:
return MapboxGL.CameraModes.Linear;
case Camera.Mode.None:
return MapboxGL.CameraModes.None;
case Camera.Mode.Move:
return MapboxGL.CameraModes.Move;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None is same as Move, but it's a bit of a mess as most implementation exports MapboxGL.CameraModes.None, but iOS on v10 only export Move

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you disable the animation on iOS?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move just jumps without animation.

#1838 (comment)

default:
Expand Down