From e9d749b775e2284b6866d362d4588a847a178e98 Mon Sep 17 00:00:00 2001 From: Antonio Zugaldia Date: Mon, 30 Nov 2015 11:32:25 -0500 Subject: add flag to let concurrent multiple infowindows to be shown --- .../java/com/mapbox/mapboxsdk/views/MapView.java | 32 ++++++++++++++++++++-- .../mapboxsdk/testapp/InfoWindowActivity.java | 3 ++ .../testapp/InfoWindowAdapterActivity.java | 3 ++ 3 files changed, 36 insertions(+), 2 deletions(-) (limited to 'android') diff --git a/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java b/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java index a5758bbeef..5a6b8c80ed 100644 --- a/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java +++ b/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java @@ -240,6 +240,7 @@ public final class MapView extends FrameLayout { private boolean mZoomEnabled = true; private boolean mScrollEnabled = true; private boolean mRotateEnabled = true; + private boolean mAllowConcurrentMultipleOpenInfoWindows = false; private String mStyleUrl; // @@ -1292,6 +1293,30 @@ public final class MapView extends FrameLayout { } } + // + // InfoWindows + // + + /** + * Changes whether the map allows concurrent multiple infowindows to be shown. + * + * @param allow If true, map allows concurrent multiple infowindows to be shown. + */ + @UiThread + public void setAllowConcurrentMultipleOpenInfoWindows(boolean allow) { + this.mAllowConcurrentMultipleOpenInfoWindows = allow; + } + + /** + * Returns whether the map allows concurrent multiple infowindows to be shown. + * + * @return If true, map allows concurrent multiple infowindows to be shown. + */ + @UiThread + public boolean isAllowConcurrentMultipleOpenInfoWindows() { + return this.mAllowConcurrentMultipleOpenInfoWindows; + } + // // Debug // @@ -2003,7 +2028,8 @@ public final class MapView extends FrameLayout { /** * Selects a marker. The selected marker will have it's info window opened. - * Any other open info windows will be closed. + * Any other open info windows will be closed unless isAllowConcurrentMultipleOpenInfoWindows() + * is true. *

* Selecting an already selected marker will have no effect. * @@ -2021,7 +2047,9 @@ public final class MapView extends FrameLayout { } // Need to deselect any currently selected annotation first - deselectMarker(marker); + if (!isAllowConcurrentMultipleOpenInfoWindows()) { + deselectMarkers(); + } boolean handledDefaultClick = false; if (mOnMarkerClickListener != null) { diff --git a/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/InfoWindowActivity.java b/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/InfoWindowActivity.java index f53f923b0e..5764b67017 100644 --- a/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/InfoWindowActivity.java +++ b/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/InfoWindowActivity.java @@ -35,6 +35,9 @@ public class InfoWindowActivity extends AppCompatActivity { mMapView.setAccessToken(ApiAccess.getToken(this)); mMapView.onCreate(savedInstanceState); + // Enable to let concurrent multiple infowindows to be shown. + //mMapView.setAllowConcurrentMultipleOpenInfoWindows(true); + mMapView.addMarker(new MarkerOptions() .title("Intersection") .snippet("H St NW with 15th St NW") diff --git a/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/InfoWindowAdapterActivity.java b/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/InfoWindowAdapterActivity.java index 0a489edaa1..97f5f3faa1 100644 --- a/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/InfoWindowAdapterActivity.java +++ b/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/InfoWindowAdapterActivity.java @@ -64,6 +64,9 @@ public class InfoWindowAdapterActivity extends AppCompatActivity { } }); + // Enable to let concurrent multiple infowindows to be shown. + //mMapView.setAllowConcurrentMultipleOpenInfoWindows(true); + mMapView.addMarker(generateMarker("Andorra", 42.505777, 1.52529, "#F44336")); mMapView.addMarker(generateMarker("Luxembourg", 49.815273, 6.129583, "#3F51B5")); mMapView.addMarker(generateMarker("Monaco", 43.738418, 7.424616, "#673AB7")); -- cgit v1.2.1