Skip to content

Commit

Permalink
Merge pull request react-native-maps#676 from opendoor-labs/move_pr
Browse files Browse the repository at this point in the history
[android] Add parameter to disable the moving on marker press
  • Loading branch information
Spike Brehm authored Oct 12, 2016
2 parents 99c3bda + e313be3 commit 722f5e9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +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="loadingBackgroundColor", customType="Color")
@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);
}

@ReactProp(name="loadingIndicatorColor", customType="Color")
@ReactProp(name = "loadingIndicatorColor", customType = "Color")
public void setLoadingIndicatorColor(AirMapView view, @Nullable Integer loadingIndicatorColor) {
view.setLoadingIndicatorColor(loadingIndicatorColor);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[] {
Expand Down Expand Up @@ -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;
}
}
});

Expand Down Expand Up @@ -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;

Expand Down
8 changes: 8 additions & 0 deletions components/MapView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down

0 comments on commit 722f5e9

Please sign in to comment.