hi,
I subclassed ItemizedOverlay and i created my custom Overlayitem
(Thumb extend Overlayitem ), my problem is, i didn't get to add or
remove dynamicaly items from the map. everytime i change moverlays i
call poupulateMap(). it's not working :(
here's my code
public class Marker extends ItemizedOverlay<Thumb> {
private GestureDetector gd;
private ArrayList<Thumb> mOverlays = new ArrayList<Thumb>();
Drawable marker;
public Marker(Drawable defaultMarker) {
super(boundCenterBottom(defaultMarker));
marker=defaultMarker;
populate();
}
public Marker(Drawable defaultMarker, Context context,
GestureDetector.OnGestureListener listener) {
super(boundCenterBottom(defaultMarker));
marker=defaultMarker;
gd = new GestureDetector(context, listener);
}
@Override
public boolean onTouchEvent(MotionEvent event, MapView mapView) {
return gd.onTouchEvent(event);
}
public ArrayList<Thumb> getmOverlays() {
return mOverlays;
}
public void setmOverlays(ArrayList<Thumb> done) {
this.mOverlays = done;
}
@Override
protected synchronized Thumb createItem(int i) {
if(i>=mOverlays.size())
return null;
return mOverlays.get(i);
}
@Override
public synchronized int size() {
return this.mOverlays.size();
}
public void addOverlay(Thumb overlay) {
mOverlays.add(overlay);
}
public void removeOverlay(Thumb overlay){
mOverlays.remove(overlay);
}
public void poupulateMap(){
populate();
setLastFocusedIndex(-1);
}
//we overrided draw so we can remove shaddow of map pins
@Override
public void draw(android.graphics.Canvas canvas,MapView
mapView,boolean shadow) {
super.draw(canvas, mapView, false);
}
@Override
protected synchronized int getIndexToDraw(int drawingOrder) {
return super.getIndexToDraw(drawingOrder);
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en