Skip to content

Commit

Permalink
[android] Add parameter to disable the moving on marker press
Browse files Browse the repository at this point in the history
  • Loading branch information
mlanter authored and Exilz committed Dec 9, 2016
1 parent 9dbe3a4 commit 9040444
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
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 9040444

Please sign in to comment.