This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -82,6 +82,10 @@ public class InfoWindowActivity extends AppCompatActivity implements OnMapReadyC
|
||||
mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(allowConcurrentInfoWindow);
|
||||
}
|
||||
|
||||
private void toggleDeselectMarkersOnTap(boolean deselectMarkersOnTap) {
|
||||
mapboxMap.getUiSettings().setDeselectMarkersOnTap(deselectMarkersOnTap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInfoWindowClick(@NonNull Marker marker) {
|
||||
Toast.makeText(getApplicationContext(), "OnClick: " + marker.getTitle(), Toast.LENGTH_LONG).show();
|
||||
@@ -157,6 +161,10 @@ public class InfoWindowActivity extends AppCompatActivity implements OnMapReadyC
|
||||
toggleConcurrentInfoWindow(!item.isChecked());
|
||||
item.setChecked(!item.isChecked());
|
||||
return true;
|
||||
case R.id.action_toggle_deselect_markers_on_tap:
|
||||
toggleDeselectMarkersOnTap(!item.isChecked());
|
||||
item.setChecked(!item.isChecked());
|
||||
return true;
|
||||
case android.R.id.home:
|
||||
onBackPressed();
|
||||
return true;
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
android:id="@+id/action_toggle_concurrent_infowindow"
|
||||
app:showAsAction="never"
|
||||
android:checkable="true"/>
|
||||
<item
|
||||
android:title="@string/menuitem_title_deselect_markers_on_tap"
|
||||
android:id="@+id/action_toggle_deselect_markers_on_tap"
|
||||
app:showAsAction="never"
|
||||
android:checkable="true"
|
||||
android:checked="true"/>
|
||||
</group>
|
||||
|
||||
</menu>
|
||||
@@ -81,7 +81,8 @@
|
||||
<string name="description_back_to_map">Restart map view after temporarily leaving to another activity</string>
|
||||
<string name="description_view_marker">Use an Android SDK View as marker</string>
|
||||
|
||||
<string name="menuitem_title_concurrent_infowindow">Concurrent Open InfoWindows</string>r
|
||||
<string name="menuitem_title_concurrent_infowindow">Concurrent Open InfoWindows</string>
|
||||
<string name="menuitem_title_deselect_markers_on_tap">Deselect Markers On Tap</string>
|
||||
<string name="menuitem_title_tracking_mode_dismiss_on_gesture">Dismiss location tracking on gesture</string>
|
||||
<string name="menuitem_title_bearing_mode_dismiss_on_gesture">Dismiss bearing tracking on gesture</string>
|
||||
<string name="menuitem_title_reset">Reset</string>
|
||||
|
||||
Reference in New Issue
Block a user