[android] #4159 - expose an api to enable selection/deselection of markers on map tap (#5312)

This commit is contained in:
Antonio Zugaldia
2016-06-13 16:20:21 -04:00
committed by GitHub
parent 8c86252103
commit 7c213e3cd0
5 changed files with 42 additions and 3 deletions

View File

@@ -1688,8 +1688,10 @@ public class MapView extends FrameLayout {
}
}
} else {
// deselect any selected marker
mMapboxMap.deselectMarkers();
if (mMapboxMap.getUiSettings().isDeselectMarkersOnTap()) {
// deselect any selected marker
mMapboxMap.deselectMarkers();
}
// notify app of map click
MapboxMap.OnMapClickListener listener = mMapboxMap.getOnMapClickListener();

View File

@@ -33,6 +33,8 @@ public class UiSettings {
private boolean zoomControlsEnabled;
private boolean deselectMarkersOnTap = true;
UiSettings(@NonNull MapView mapView) {
this.mapView = mapView;
this.compassSettings = new ViewSettings();
@@ -483,6 +485,26 @@ public class UiSettings {
return zoomControlsEnabled;
}
/**
* Gets whether the markers are automatically deselected (and therefore, their infowindows
* closed) when a map tap is detected.
* @return If true, markers are deselected on a map tap.
*/
public boolean isDeselectMarkersOnTap() {
return deselectMarkersOnTap;
}
/**
* Sets whether the markers are automatically deselected (and therefore, their infowindows
* closed) when a map tap is detected.
*
* @param deselectMarkersOnTap
*/
public void setDeselectMarkersOnTap(boolean deselectMarkersOnTap) {
this.deselectMarkersOnTap = deselectMarkersOnTap;
}
/**
* <p>
* Changes whether the user may scroll around the map.