From ba0da102a954321f730f3d21a26caebe48cedc3b Mon Sep 17 00:00:00 2001 From: bsudekum Date: Mon, 14 Dec 2015 10:09:23 -0800 Subject: [PATCH] Add more --- .../ReactNativeMapboxGLManager.java | 73 ++++++++++++------- .../ReactNativeMapboxGLModule.java | 16 ++-- index.android.js | 20 +++-- 3 files changed, 67 insertions(+), 42 deletions(-) diff --git a/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLManager.java b/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLManager.java index ec9ceb2..d4acde8 100644 --- a/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLManager.java +++ b/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLManager.java @@ -33,7 +33,6 @@ public class ReactNativeMapboxGLManager extends SimpleViewManager { public static final String PROP_ACCESS_TOKEN = "accessToken"; public static final String PROP_ANNOTATIONS = "annotations"; public static final String PROP_CENTER_COORDINATE = "centerCoordinate"; - public static final String PROP_CENTER_COORDINATE_ZOOM = "centerCoordinateZoom"; public static final String PROP_DEBUG_ACTIVE = "debugActive"; public static final String PROP_DIRECTION = "direction"; public static final String PROP_ONREGIONCHANGE = "onRegionChange"; @@ -45,9 +44,10 @@ public class ReactNativeMapboxGLManager extends SimpleViewManager { public static final String PROP_USER_TRACKING_MODE = "UserLocationTrackingMode"; public static final String PROP_ZOOM_ENABLED = "zoomEnabled"; public static final String PROP_ZOOM_LEVEL = "zoomLevel"; - public static final String PROP_REMOVE_ALL_ANNOTATIONS = "removeAllAnnotations"; public static final String PROP_SET_TILT = "tilt"; - public static final String PROP_VISIBLE_COORDINATE_BOUNDS = "visibleCoordinateBounds"; + public static final String PROP_COMPASS_IS_HIDDEN = "compassIsHidden"; + public static final String PROP_LOGO_IS_HIDDEN = "logoIsHidden"; + public static final String PROP_ATTRIBUTION_IS_HIDDEN = "attributionButtonIsHidden"; private MapView mapView; @@ -72,11 +72,6 @@ public class ReactNativeMapboxGLManager extends SimpleViewManager { } } - @ReactProp(name = PROP_REMOVE_ALL_ANNOTATIONS) - public void removeAllAnnotations(MapView view, @Nullable Boolean placeHolder) { - view.removeAllAnnotations(); - } - @ReactProp(name = PROP_SET_TILT) public void setTilt(MapView view, @Nullable double pitch) { mapView.setTilt(pitch, 1L); @@ -214,25 +209,6 @@ public class ReactNativeMapboxGLManager extends SimpleViewManager { } } - @ReactProp(name = PROP_CENTER_COORDINATE_ZOOM) - public void setCenterCoordinateZoomLevel(MapView view, @Nullable ReadableMap center) { - if (center != null) { - double latitude = center.getDouble("latitude"); - double longitude = center.getDouble("longitude"); - double zoom = center.getDouble("zoom"); - view.setCenterCoordinate(new LatLng(latitude, longitude, zoom), true); - }else{ - Log.w(REACT_CLASS, "No CenterCoordinate provided"); - } - } - - @ReactProp(name = PROP_VISIBLE_COORDINATE_BOUNDS) - public void setVisibleCoordinateBounds(MapView view, @Nullable ReadableMap info) { - final LatLng sw = new LatLng(info.getDouble("latSW"), info.getDouble("lngSW")); - final LatLng ne = new LatLng(info.getDouble("latNE"), info.getDouble("lngNE")); - view.setVisibleCoordinateBounds(new CoordinateBounds(sw, ne), new RectF((float)info.getDouble("paddingLeft"), (float)info.getDouble("paddingTop"), (float)info.getDouble("paddingRight"), (float)info.getDouble("paddingBottom")), true); - } - @ReactProp(name = PROP_ROTATION_ENABLED, defaultBoolean = true) public void setRotateEnabled(MapView view, Boolean value) { view.setRotateEnabled(value); @@ -281,6 +257,49 @@ public class ReactNativeMapboxGLManager extends SimpleViewManager { view.setScrollEnabled(value); } + @ReactProp(name = PROP_COMPASS_IS_HIDDEN) + public void setCompassIsHidden(MapView view, Boolean value) { + view.setCompassEnabled(value); + } + + @ReactProp(name = PROP_LOGO_IS_HIDDEN) + public void setLogoIsHidden(MapView view, Boolean value) { + if (value) { + view.setLogoVisibility(0); + } else { + view.setLogoVisibility(1); + } + } + + @ReactProp(name = PROP_ATTRIBUTION_IS_HIDDEN) + public void setAttributionIsHidden(MapView view, Boolean value) { + if (value) { + view.setAttributionVisibility(0); + } else { + view.setAttributionVisibility(1); + } + } + + public void setCenterCoordinateZoomLevel(MapView view, @Nullable ReadableMap center) { + if (center != null) { + double latitude = center.getDouble("latitude"); + double longitude = center.getDouble("longitude"); + double zoom = center.getDouble("zoom"); + view.setCenterCoordinate(new LatLng(latitude, longitude, zoom), true); + }else{ + Log.w(REACT_CLASS, "No CenterCoordinate provided"); + } + } + + public void setVisibleCoordinateBounds(MapView view, @Nullable ReadableMap info) { + final LatLng sw = new LatLng(info.getDouble("latSW"), info.getDouble("lngSW")); + final LatLng ne = new LatLng(info.getDouble("latNE"), info.getDouble("lngNE")); + view.setVisibleCoordinateBounds(new CoordinateBounds(sw, ne), new RectF((float) info.getDouble("paddingLeft"), (float) info.getDouble("paddingTop"), (float) info.getDouble("paddingRight"), (float) info.getDouble("paddingBottom")), true); + } + + public void removeAllAnnotations(MapView view, @Nullable Boolean placeHolder) { + view.removeAllAnnotations(); + } public MapView getMapView() { return mapView; diff --git a/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLModule.java b/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLModule.java index 094e14a..7464e73 100644 --- a/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLModule.java +++ b/android/src/main/java/com/mapbox/reactnativemapboxgl/ReactNativeMapboxGLModule.java @@ -36,12 +36,12 @@ public class ReactNativeMapboxGLModule extends ReactContextBaseJavaModule { } @ReactMethod - public void setDirectionAnimated(int direction) { + public void setDirectionAnimated(double mapRef, int direction) { aPackage.getManager().setDirection(aPackage.getManager().getMapView(), direction); } @ReactMethod - public void setCenterCoordinateAnimated(double latitude, double longitude) { + public void setCenterCoordinateAnimated(double mapRef, double latitude, double longitude) { WritableMap location = Arguments.createMap(); location.putDouble("latitude", latitude); location.putDouble("longitude", longitude); @@ -49,7 +49,7 @@ public class ReactNativeMapboxGLModule extends ReactContextBaseJavaModule { } @ReactMethod - public void setCenterCoordinateZoomLevelAnimated(double latitude, double longitude, double zoom) { + public void setCenterCoordinateZoomLevelAnimated(double mapRef, double latitude, double longitude, double zoom) { WritableMap location = Arguments.createMap(); location.putDouble("latitude", latitude); location.putDouble("longitude", longitude); @@ -58,27 +58,27 @@ public class ReactNativeMapboxGLModule extends ReactContextBaseJavaModule { } @ReactMethod - public void addAnnotations(ReadableArray value) { + public void addAnnotations(double mapRef, ReadableArray value) { aPackage.getManager().setAnnotations(aPackage.getManager().getMapView(), value); } @ReactMethod - public void setUserTrackingMode(String mode) { + public void setUserTrackingMode(double mapRef, String mode) { aPackage.getManager().setMyLocationTrackingMode(aPackage.getManager().getMapView(), mode); } @ReactMethod - public void removeAllAnnotations() { + public void removeAllAnnotations(double mapRef) { aPackage.getManager().removeAllAnnotations(aPackage.getManager().getMapView(), true); } @ReactMethod - public void setTilt(double pitch) { + public void setTilt(double mapRef, double pitch) { aPackage.getManager().setTilt(aPackage.getManager().getMapView(), pitch); } @ReactMethod - public void setVisibleCoordinateBoundsAnimated(double latSW, double lngSW,double latNE, double lngNE, float paddingTop, float paddingRight, float paddingBottom, float paddingLeft) { + public void setVisibleCoordinateBoundsAnimated(double mapRef, double latSW, double lngSW,double latNE, double lngNE, float paddingTop, float paddingRight, float paddingBottom, float paddingLeft) { WritableMap info = Arguments.createMap(); info.putDouble("latSW", latSW); info.putDouble("lngSW", lngSW); diff --git a/index.android.js b/index.android.js index 614f465..b4ba1dd 100644 --- a/index.android.js +++ b/index.android.js @@ -31,10 +31,11 @@ var ReactMapView = requireNativeComponent('RCTMapbox', { zoomEnabled: React.PropTypes.bool, zoomLevel: React.PropTypes.number, tilt: React.PropTypes.number, + logoIsHidden: React.PropTypes.bool, + attributionButtonIsHidden: React.PropTypes.bool, + compassIsHidden: React.PropTypes.bool, onRegionChange: React.PropTypes.func, onUserLocationChange: React.PropTypes.func, - removeAllAnnotations: React.PropTypes.func, - visibleCoordinateBounds: React.PropTypes.func, // Fix for https://github.com/mapbox/react-native-mapbox-gl/issues/118 scaleY: React.PropTypes.number, scaleX: React.PropTypes.number, @@ -65,7 +66,10 @@ var ReactMapView = requireNativeComponent('RCTMapbox', { UserLocationTrackingMode: 'NONE', zoomEnabled: true, zoomLevel: 0, - tilt: 0 + tilt: 0, + attributionButtonIsHidden: false, + logoIsHidden: false, + compassIsHidden: false }; } }); @@ -81,10 +85,12 @@ var ReactMapViewWrapper = React.createClass({ if (this.props.onUserLocationChange) this.props.onUserLocationChange(event.nativeEvent.src); }, render() { - return + return ( + + ); } });