Fixed geopoint deletion and update
This commit is contained in:
parent
13287f5b05
commit
5949099d91
@ -25,6 +25,7 @@ import org.osmdroid.views.CustomZoomButtonsController;
|
||||
import org.osmdroid.views.MapView;
|
||||
import org.osmdroid.views.overlay.MapEventsOverlay;
|
||||
import org.osmdroid.views.overlay.Marker;
|
||||
import org.osmdroid.views.overlay.Overlay;
|
||||
import org.osmdroid.views.overlay.infowindow.InfoWindow;
|
||||
import org.osmdroid.views.overlay.mylocation.GpsMyLocationProvider;
|
||||
import org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay;
|
||||
@ -108,6 +109,7 @@ public class GeofavoriteMapFragment extends GeofavoritesFragment implements Main
|
||||
mGeofavoritesFragmentViewModel.getGeofavorites().observe(getViewLifecycleOwner(), new Observer<List<Geofavorite>>() {
|
||||
@Override
|
||||
public void onChanged(List<Geofavorite> geofavorites) {
|
||||
clearAllMarkers();
|
||||
for(Geofavorite gf : geofavorites)
|
||||
addMarker(gf);
|
||||
map.invalidate();
|
||||
@ -222,4 +224,15 @@ public class GeofavoriteMapFragment extends GeofavoritesFragment implements Main
|
||||
m.setInfoWindow(iw);
|
||||
map.getOverlays().add(m);
|
||||
}
|
||||
|
||||
private void clearAllMarkers() {
|
||||
// Close any open infowindow before removing related marker
|
||||
InfoWindow.closeAllInfoWindowsOn(map);
|
||||
// Remove all markers, leaving the other overlays (user position and tap listener ones)
|
||||
for(Overlay o : map.getOverlays()) {
|
||||
if (o instanceof Marker) {
|
||||
map.getOverlays().remove(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user