Skip to content

Commit e5d9140

Browse files
committed
Map marker selection and footer visibility now track together.
1 parent 3a94275 commit e5d9140

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

app/src/main/java/fr/free/nrw/commons/nearby/NearbyMapFragment.java

+12
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.google.gson.GsonBuilder;
2525
import com.google.gson.reflect.TypeToken;
2626
import com.mapbox.mapboxsdk.Mapbox;
27+
import com.mapbox.mapboxsdk.annotations.Marker;
2728
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
2829
import com.mapbox.mapboxsdk.annotations.PolygonOptions;
2930
import com.mapbox.mapboxsdk.camera.CameraPosition;
@@ -76,6 +77,7 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
7677
private Animation rotate_forward;
7778

7879
private Place place;
80+
private Marker selected;
7981

8082
public NearbyMapFragment() {
8183
}
@@ -135,6 +137,8 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
135137
else if (bottomSheetDetailsBehavior.getState() == BottomSheetBehavior
136138
.STATE_COLLAPSED) {
137139
bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
140+
mapView.getMapAsync(MapboxMap::deselectMarkers);
141+
selected=null;
138142
return true;
139143
}
140144
}
@@ -250,8 +254,15 @@ private void setupMapView(Bundle savedInstanceState) {
250254
mapView.getMapAsync(mapboxMap -> {
251255
mapboxMap.addMarkers(baseMarkerOptions);
252256

257+
mapboxMap.setOnInfoWindowCloseListener(marker -> {
258+
if (marker == selected){
259+
bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
260+
}
261+
});
262+
253263
mapboxMap.setOnMarkerClickListener(marker -> {
254264
if (marker instanceof NearbyMarker) {
265+
this.selected = marker;
255266
NearbyMarker nearbyMarker = (NearbyMarker) marker;
256267
Place place = nearbyMarker.getNearbyBaseMarker().getPlace();
257268
passInfoToSheet(place);
@@ -325,6 +336,7 @@ public void prepareViewsForSheetPosition(int bottomSheetState) {
325336
this.getView().requestFocus();
326337
break;
327338
case (BottomSheetBehavior.STATE_HIDDEN):
339+
mapView.getMapAsync(MapboxMap::deselectMarkers);
328340
transparentView.setClickable(false);
329341
transparentView.setAlpha(0);
330342
closeFabs(isFabOpen);

0 commit comments

Comments
 (0)