added custom overlay

This commit is contained in:
Sem van der Hoeven
2020-12-17 14:22:20 +01:00
parent 95a2e4e849
commit 610b23b056
4 changed files with 63 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
package com.a1.nextlocation.recyclerview;
import android.graphics.Point;
import android.graphics.drawable.Drawable;
import org.osmdroid.api.IMapView;
import org.osmdroid.views.MapView;
import org.osmdroid.views.overlay.ItemizedOverlay;
import org.osmdroid.views.overlay.OverlayItem;
import java.util.ArrayList;
public class CustomOverlay extends ItemizedOverlay<OverlayItem> {
private final MapView mapView;
private ArrayList<OverlayItem> overlayItems = new ArrayList<>();
public CustomOverlay(Drawable pDefaultMarker, MapView mapView) {
super(pDefaultMarker);
this.mapView = mapView;
}
public void addOverlayItem(OverlayItem item) {
overlayItems.add(item);
populate();
}
@Override
protected OverlayItem createItem(int i) {
return overlayItems.get(i);
}
@Override
public int size() {
return overlayItems.size();
}
@Override
public boolean onSnapToItem(int x, int y, Point snapPoint, IMapView mapView) {
return true;
}
}

View File

@@ -4,6 +4,8 @@ import android.content.Context;
import com.a1.nextlocation.data.Location;
import org.osmdroid.util.GeoPoint;
import java.util.ArrayList;
import java.util.List;
@@ -30,4 +32,5 @@ public enum LocationListManager {
LocationLoader locationLoader = new LocationLoader(this.context);
this.locationList = locationLoader.load();
}
}