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.MapView;
|
||||||
import org.osmdroid.views.overlay.MapEventsOverlay;
|
import org.osmdroid.views.overlay.MapEventsOverlay;
|
||||||
import org.osmdroid.views.overlay.Marker;
|
import org.osmdroid.views.overlay.Marker;
|
||||||
|
import org.osmdroid.views.overlay.Overlay;
|
||||||
import org.osmdroid.views.overlay.infowindow.InfoWindow;
|
import org.osmdroid.views.overlay.infowindow.InfoWindow;
|
||||||
import org.osmdroid.views.overlay.mylocation.GpsMyLocationProvider;
|
import org.osmdroid.views.overlay.mylocation.GpsMyLocationProvider;
|
||||||
import org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay;
|
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>>() {
|
mGeofavoritesFragmentViewModel.getGeofavorites().observe(getViewLifecycleOwner(), new Observer<List<Geofavorite>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(List<Geofavorite> geofavorites) {
|
public void onChanged(List<Geofavorite> geofavorites) {
|
||||||
|
clearAllMarkers();
|
||||||
for(Geofavorite gf : geofavorites)
|
for(Geofavorite gf : geofavorites)
|
||||||
addMarker(gf);
|
addMarker(gf);
|
||||||
map.invalidate();
|
map.invalidate();
|
||||||
@ -222,4 +224,15 @@ public class GeofavoriteMapFragment extends GeofavoritesFragment implements Main
|
|||||||
m.setInfoWindow(iw);
|
m.setInfoWindow(iw);
|
||||||
map.getOverlays().add(m);
|
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