Android wie malen in MapView mit Overlay in freier Hand zu zeichnen?

In meiner App Zeichne Farbe in freier Hand in der Kartenansicht, aber suche viele Informationen, die schließlich aus der Rechteckform stammen. Zeichne in der Kartenansicht, aber ich möchte anstelle des Rechtecks ​​freie Hand wie im Zickzack zeichnen, wie ich meinen Code ändere.

MapOverlay.java

  public class MapOverlay extends Overlay {

private float x1,y1,x2,y2;
private GeoPoint p1=null,p2=null;
private MapExampleActivity mv = null;
private Paint paint = new Paint();
private Path path = new Path();
private boolean isUp = false;

//constructor receiving the initial point
  public MapOverlay(MapExampleActivity mapV,float x,float y){
    paint.setStrokeWidth(2.0f);
    x1 = x;
    y1 = y;
    mv = mapV;
    p1 = mapV.getMapView().getProjection().fromPixels((int)x1,(int)y1);
}
//override draw method to add our custom drawings
@Override
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {

    if(p1 != null && p2 != null){
        //get the 2 geopoints defining the area and transform them to pixels
        //this way if we move or zoom the map rectangle will follow accordingly
        Point screenPts1 = new Point();
        mapView.getProjection().toPixels(p1, screenPts1);
        Point screenPts2 = new Point();
        mapView.getProjection().toPixels(p2, screenPts2);                

        //draw inner rectangle
        paint.setColor(Color.BLUE);
     //   paint.setStyle(Style.FILL);
        canvas.drawPath(path, paint);       
        canvas.drawRect(screenPts1.x, screenPts1.y, screenPts2.x, screenPts2.y, paint);
        //draw outline rectangle

    //  paint.setColor(Color.YELLOW);
        paint.setStyle(Style.STROKE);
    //  canvas.drawRect(screenPts1.x, screenPts1.y, screenPts2.x, screenPts2.y, paint);
        canvas.drawPath(path, paint); 
    }
    return true;
}    

@Override
public boolean onTouchEvent(MotionEvent e, MapView mapView) {
    if(mv.isEditMode() && !isUp){

        if(e.getAction() == MotionEvent.ACTION_DOWN){
            x1 = y1 = 0;
            x1 = e.getX();
            y1 = e.getY();
            p1 = mapView.getProjection().fromPixels((int)x1,(int)y1);               
        }

        //here we constantly change geopoint p2 as we move out finger
        if(e.getAction() == MotionEvent.ACTION_MOVE){
            x2 = e.getX();
            y2 = e.getY();
            p2 = mapView.getProjection().fromPixels((int)x2,(int)y2);               
        }

        //---when user lifts his finger---
        if (e.getAction() == MotionEvent.ACTION_UP) {                
            isUp = true;
        }    
        return true;
    }
    return false;
}

}

mit diesem kann ich zeichnen wie dieses rechteck formen und zeichnen bis du wieder auf den umschaltknopf klickst (mehrmals zeichnen möglich)

Ich möchte Linien anstelle von Rechtecken wie unter dem Bild zeichnen (mehrmals zeichnen).

Schließlich fand ich diesen Link dieser Link bieten Rechteckform zeichnenhttp://n3vrax.wordpress.com/2011/08/13/drawing-overlays-on-android-map-view/

Ändern Sie einfach das Rechteck, um eine Idee frei zu zeichnen.

Antworten auf die Frage(1)

Ihre Antwort auf die Frage