From 3433a7aac50224091b2dd4542ef579703b02c322 Mon Sep 17 00:00:00 2001 From: Matt Lanter Date: Mon, 10 Oct 2016 18:58:53 -0700 Subject: [PATCH 1/2] [android] Add parameter to disable the moving on marker press --- .../airbnb/android/react/maps/AirMapManager.java | 5 +++++ .../com/airbnb/android/react/maps/AirMapView.java | 14 +++++++++++++- components/MapView.js | 8 ++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/airbnb/android/react/maps/AirMapManager.java b/android/src/main/java/com/airbnb/android/react/maps/AirMapManager.java index b35737021..2f6e30d46 100644 --- a/android/src/main/java/com/airbnb/android/react/maps/AirMapManager.java +++ b/android/src/main/java/com/airbnb/android/react/maps/AirMapManager.java @@ -165,6 +165,11 @@ public void setLoadingEnabled(AirMapView view, boolean loadingEnabled) { view.enableMapLoading(loadingEnabled); } + @ReactProp(name="moveOnMarkerPress", defaultBoolean = true) + public void setMoveOnMarkerPress(AirMapView view, boolean moveOnPress) { + view.setMoveOnMarkerPress(moveOnPress); + } + @ReactProp(name="loadingBackgroundColor", customType="Color") public void setLoadingBackgroundColor(AirMapView view, @Nullable Integer loadingBackgroundColor) { view.setLoadingBackgroundColor(loadingBackgroundColor); diff --git a/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java b/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java index 4a04af88a..faae1a002 100644 --- a/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java +++ b/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java @@ -65,6 +65,7 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter, private boolean isMonitoringRegion = false; private boolean isTouchDown = false; private boolean handlePanDrag = false; + private boolean moveOnMarkerPress = true; private boolean cacheEnabled = false; private static final String[] PERMISSIONS = new String[] { @@ -154,7 +155,14 @@ public boolean onMarkerClick(Marker marker) { event.putString("action", "marker-press"); manager.pushEvent(markerMap.get(marker), "onPress", event); - return false; // returning false opens the callout window, if possible + // Return false to open the callout info window and center on the marker + // https://developers.google.com/android/reference/com/google/android/gms/maps/GoogleMap.OnMarkerClickListener + if (view.moveOnMarkerPress) { + return false; + } else { + marker.showInfoWindow(); + return true; + } } }); @@ -330,6 +338,10 @@ public void enableMapLoading(boolean loadingEnabled) { } } + public void setMoveOnMarkerPress(boolean moveOnPress) { + this.moveOnMarkerPress = moveOnPress; + } + public void setLoadingBackgroundColor(Integer loadingBackgroundColor) { this.loadingBackgroundColor = loadingBackgroundColor; diff --git a/components/MapView.js b/components/MapView.js index 429a71133..a7762665d 100644 --- a/components/MapView.js +++ b/components/MapView.js @@ -167,6 +167,14 @@ const propTypes = { */ toolbarEnabled: PropTypes.bool, + /** + * A Boolean indicating whether on marker press the map will move to the pressed marker + * Default value is `true` + * + * @platform android + */ + moveOnMarkerPress: PropTypes.bool, + /** * A Boolean indicating whether the map shows scale information. * Default value is `false` From e313be38f1f1820fda6c6dc7f8d9442224ac4595 Mon Sep 17 00:00:00 2001 From: Matt Lanter Date: Tue, 11 Oct 2016 16:13:24 -0700 Subject: [PATCH 2/2] Add spaces around `=` --- .../com/airbnb/android/react/maps/AirMapManager.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/android/src/main/java/com/airbnb/android/react/maps/AirMapManager.java b/android/src/main/java/com/airbnb/android/react/maps/AirMapManager.java index 2f6e30d46..b31106dca 100644 --- a/android/src/main/java/com/airbnb/android/react/maps/AirMapManager.java +++ b/android/src/main/java/com/airbnb/android/react/maps/AirMapManager.java @@ -155,27 +155,27 @@ public void setRotateEnabled(AirMapView view, boolean rotateEnabled) { view.map.getUiSettings().setRotateGesturesEnabled(rotateEnabled); } - @ReactProp(name="cacheEnabled", defaultBoolean = false) + @ReactProp(name = "cacheEnabled", defaultBoolean = false) public void setCacheEnabled(AirMapView view, boolean cacheEnabled) { view.setCacheEnabled(cacheEnabled); } - @ReactProp(name="loadingEnabled", defaultBoolean = false) + @ReactProp(name = "loadingEnabled", defaultBoolean = false) public void setLoadingEnabled(AirMapView view, boolean loadingEnabled) { view.enableMapLoading(loadingEnabled); } - @ReactProp(name="moveOnMarkerPress", defaultBoolean = true) + @ReactProp(name = "moveOnMarkerPress", defaultBoolean = true) public void setMoveOnMarkerPress(AirMapView view, boolean moveOnPress) { view.setMoveOnMarkerPress(moveOnPress); } - @ReactProp(name="loadingBackgroundColor", customType="Color") + @ReactProp(name = "loadingBackgroundColor", customType = "Color") public void setLoadingBackgroundColor(AirMapView view, @Nullable Integer loadingBackgroundColor) { view.setLoadingBackgroundColor(loadingBackgroundColor); } - @ReactProp(name="loadingIndicatorColor", customType="Color") + @ReactProp(name = "loadingIndicatorColor", customType = "Color") public void setLoadingIndicatorColor(AirMapView view, @Nullable Integer loadingIndicatorColor) { view.setLoadingIndicatorColor(loadingIndicatorColor); }