More mutable itemized layer
This commit is contained in:
@@ -23,19 +23,14 @@ import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.oscim.android.canvas.AndroidGraphics;
|
||||
import org.oscim.core.BoundingBox;
|
||||
import org.oscim.core.GeoPoint;
|
||||
import org.oscim.layers.marker.MarkerInterface;
|
||||
import org.oscim.layers.marker.MarkerSymbol;
|
||||
import org.oscim.layers.marker.MarkerSymbol.HotspotPlace;
|
||||
import org.oscim.map.Map;
|
||||
import org.osmdroid.location.FlickrPOIProvider;
|
||||
import org.osmdroid.location.FourSquareProvider;
|
||||
import org.osmdroid.location.GeoNamesPOIProvider;
|
||||
import org.osmdroid.location.NominatimPOIProvider;
|
||||
import org.osmdroid.location.POI;
|
||||
import org.osmdroid.location.PicasaPOIProvider;
|
||||
import org.osmdroid.location.*;
|
||||
import org.osmdroid.overlays.DefaultInfoWindow;
|
||||
import org.osmdroid.overlays.ExtendedMarkerItem;
|
||||
import org.osmdroid.overlays.ItemizedOverlayWithBubble;
|
||||
@@ -45,7 +40,7 @@ import java.util.List;
|
||||
|
||||
public class POISearch {
|
||||
private final ArrayList<POI> mPOIs;
|
||||
ItemizedOverlayWithBubble<ExtendedMarkerItem> poiMarkers;
|
||||
ItemizedOverlayWithBubble poiMarkers;
|
||||
MarkerSymbol[] mMarkers;
|
||||
|
||||
private static final int MDEFAULT = 0;
|
||||
@@ -57,9 +52,9 @@ public class POISearch {
|
||||
POISearch() {
|
||||
mPOIs = new ArrayList<POI>();
|
||||
//POI markers:
|
||||
final ArrayList<ExtendedMarkerItem> poiItems = new ArrayList<ExtendedMarkerItem>();
|
||||
final ArrayList<MarkerInterface> poiItems = new ArrayList<>();
|
||||
|
||||
poiMarkers = new ItemizedOverlayWithBubble<ExtendedMarkerItem>(App.map,
|
||||
poiMarkers = new ItemizedOverlayWithBubble(App.map,
|
||||
App.activity,
|
||||
null,
|
||||
poiItems,
|
||||
|
||||
@@ -24,10 +24,10 @@ import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.oscim.android.canvas.AndroidGraphics;
|
||||
import org.oscim.core.GeoPoint;
|
||||
import org.oscim.layers.PathLayer;
|
||||
import org.oscim.layers.marker.MarkerInterface;
|
||||
import org.oscim.layers.marker.MarkerSymbol;
|
||||
import org.oscim.layers.marker.MarkerSymbol.HotspotPlace;
|
||||
import org.osmdroid.location.GeocoderNominatim;
|
||||
@@ -48,7 +48,7 @@ public class RouteSearch {
|
||||
|
||||
private final PathLayer mRouteOverlay;
|
||||
//private final ItemizedOverlayWithBubble<ExtendedOverlayItem> mRouteMarkers;
|
||||
private final ItemizedOverlayWithBubble<ExtendedMarkerItem> mItineraryMarkers;
|
||||
private final ItemizedOverlayWithBubble mItineraryMarkers;
|
||||
|
||||
private final RouteBar mRouteBar;
|
||||
|
||||
@@ -63,9 +63,9 @@ public class RouteSearch {
|
||||
mViaPoints = new ArrayList<GeoPoint>();
|
||||
|
||||
// Itinerary markers:
|
||||
ArrayList<ExtendedMarkerItem> waypointsItems = new ArrayList<ExtendedMarkerItem>();
|
||||
ArrayList<MarkerInterface> waypointsItems = new ArrayList<>();
|
||||
|
||||
mItineraryMarkers = new ItemizedOverlayWithBubble<ExtendedMarkerItem>(App.map,
|
||||
mItineraryMarkers = new ItemizedOverlayWithBubble(App.map,
|
||||
App.activity,
|
||||
null,
|
||||
waypointsItems,
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.osmdroid.overlays;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import org.oscim.app.App;
|
||||
import org.oscim.core.GeoPoint;
|
||||
import org.oscim.core.MapPosition;
|
||||
@@ -10,6 +9,7 @@ import org.oscim.core.Point;
|
||||
import org.oscim.event.Event;
|
||||
import org.oscim.event.MotionEvent;
|
||||
import org.oscim.layers.marker.ItemizedLayer;
|
||||
import org.oscim.layers.marker.MarkerInterface;
|
||||
import org.oscim.layers.marker.MarkerItem;
|
||||
import org.oscim.layers.marker.MarkerSymbol;
|
||||
import org.oscim.map.Map;
|
||||
@@ -22,14 +22,12 @@ import java.util.List;
|
||||
* taps on an overlay item, and displays item attributes. <br>
|
||||
* Items must be ExtendedMarkerItem. <br>
|
||||
*
|
||||
* @param <Item> ...
|
||||
* @author M.Kergall
|
||||
* @see ExtendedMarkerItem
|
||||
* @see InfoWindow
|
||||
*/
|
||||
public class ItemizedOverlayWithBubble<Item extends MarkerItem> extends
|
||||
ItemizedLayer<Item> implements
|
||||
ItemizedLayer.OnItemGestureListener<Item>, Map.UpdateListener {
|
||||
public class ItemizedOverlayWithBubble extends ItemizedLayer
|
||||
implements ItemizedLayer.OnItemGestureListener<MarkerInterface>, Map.UpdateListener {
|
||||
|
||||
/* only one for all items of this overlay => one at a time */
|
||||
protected InfoWindow mBubble;
|
||||
@@ -40,7 +38,7 @@ public class ItemizedOverlayWithBubble<Item extends MarkerItem> extends
|
||||
static int layoutResId = 0;
|
||||
|
||||
public ItemizedOverlayWithBubble(Map map, Context context,
|
||||
MarkerSymbol marker, List<Item> list, InfoWindow bubble) {
|
||||
MarkerSymbol marker, List<MarkerInterface> list, InfoWindow bubble) {
|
||||
super(map, list, marker, null);
|
||||
|
||||
if (bubble != null) {
|
||||
@@ -66,12 +64,12 @@ public class ItemizedOverlayWithBubble<Item extends MarkerItem> extends
|
||||
}
|
||||
|
||||
public ItemizedOverlayWithBubble(Map map, Context context,
|
||||
MarkerSymbol marker, List<Item> aList) {
|
||||
MarkerSymbol marker, List<MarkerInterface> aList) {
|
||||
this(map, context, marker, aList, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemLongPress(int index, MarkerItem item) {
|
||||
public boolean onItemLongPress(int index, MarkerInterface item) {
|
||||
if (mBubble.isOpen())
|
||||
hideBubble();
|
||||
else
|
||||
@@ -80,7 +78,7 @@ public class ItemizedOverlayWithBubble<Item extends MarkerItem> extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemSingleTapUp(int index, MarkerItem item) {
|
||||
public boolean onItemSingleTapUp(int index, MarkerInterface item) {
|
||||
showBubble(index);
|
||||
|
||||
return true;
|
||||
@@ -121,7 +119,6 @@ public class ItemizedOverlayWithBubble<Item extends MarkerItem> extends
|
||||
*
|
||||
* @param index of the overlay item to show
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void showBubbleOnItem(int index) {
|
||||
ExtendedMarkerItem item = (ExtendedMarkerItem) (mItemList.get(index));
|
||||
mItemWithBubble = item;
|
||||
@@ -131,7 +128,7 @@ public class ItemizedOverlayWithBubble<Item extends MarkerItem> extends
|
||||
mMap.animator().animateTo(item.geoPoint);
|
||||
|
||||
mMap.updateMap(true);
|
||||
setFocus((Item) item);
|
||||
setFocus(item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +176,7 @@ public class ItemizedOverlayWithBubble<Item extends MarkerItem> extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean removeItem(final Item item) {
|
||||
public synchronized boolean removeItem(final MarkerInterface item) {
|
||||
boolean result = super.removeItem(item);
|
||||
if (mItemWithBubble == item) {
|
||||
hideBubble();
|
||||
|
||||
Reference in New Issue
Block a user