Ok, i try it :) 1. I track gps points in my app and draw my route on a MapView:
@Override public void onLocationChanged(Location loc) { if (loc != null) { latitude = loc.getLatitude(); longitude = loc.getLongitude(); if(first) { p1 = new GeoPoint((int) (loc.getLatitude()*1E6), (int) (loc.getLongitude()*1E6)); mc.animateTo(p1); mc.setZoom(18); first=false; //act_pos = new TrackOverlay(p1, p1,1); I NOW USE MYLOCATIONOVERLAY //map.getOverlays().add(act_pos); mlo = new MyLocationOverlay(TRACKing.this, map); map.getOverlays().add(mlo); mlo.enableMyLocation(); mlo.runOnFirstFix(new Runnable() { public void run() { mc.animateTo(mlo.getMyLocation()); } }); } else { p2 = p1; p1 = new GeoPoint((int) (loc.getLatitude()*1E6), (int) (loc.getLongitude()*1E6)); to = new TrackOverlay(p1, p2, 0); //act_pos.setGeoPoints(p1, p2); I NOW USE MYLOCATIONOVERLAY map.getOverlays().add(to); mc.animateTo(p1); map.invalidate(); } } } 2. My TrackOverlay class: public class TrackOverlay extends Overlay implements Parcelable { private static final int TRACK = 0; private GeoPoint gp1, gp2; private int mode; public TrackOverlay(GeoPoint gp1,GeoPoint gp2, int mode) { this.gp1 = gp1; this.gp2 = gp2; this.mode = mode; } public void setGeoPoints (GeoPoint gp1, GeoPoint gp2) { this.gp1 = gp1; this.gp2 = gp2; } @Override public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) { Projection projection = mapView.getProjection(); if (shadow == false) { Paint paint = new Paint(); paint.setAntiAlias(true); Point point = new Point(); if(gp1!=null && gp2 != null) { projection.toPixels(gp1, point); if(mode==TRACK) { paint.setColor(Color.BLUE); Point point2 = new Point(); projection.toPixels(gp2, point2); paint.setStrokeWidth(5); paint.setAlpha(120); canvas.drawLine(point.x, point.y, point2.x,point2.y, paint); } else //atm nothing to do } } return super.draw(canvas, mapView, shadow, when); } @Override public int describeContents() { // TODO Auto-generated method stub return 0; } @Override public void writeToParcel(Parcel dest, int flags) { // TODO Auto-generated method stub } private TrackOverlay (Parcel in) { } public static final Parcelable.Creator<TrackOverlay> CREATOR = new Parcelable.Creator<TrackOverlay>() { public TrackOverlay createFromParcel(Parcel in) { return new TrackOverlay(in); } public TrackOverlay[] newArray(int size) { return new TrackOverlay[size]; } }; } 3. If i want to describe a specific point, i start a new activity (via menue). and if i come back to this activity, i cant see the overlays any more. So how can I save my overlays?? Thanks, Stefan PS: I hope this help you...
-- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en