Adding visible "Markers" to represent Geopoints to a MapView using ItemizedOverlay in Android

I am building an application which stores GPS locations in a SQLite database and then outputs the data onto a MapView using an Overlay by drawing a red line between the points.

I want to be able to show graphical markers (images) for each of these points as well as the red line. My code is as follows:

public class MyOverlay extends ItemizedOverlay<OverlayItem> {

// private Projection projection;
private Paint linePaint;
private Vector<GeoPoint> points;

public MyOverlay(Drawable defaultMarker) {
    super(defaultMarker);
    points = new Vector<GeoPoint>();
    //set colour, stroke width etc.
    linePaint = new Paint();
    linePaint.setARGB(255, 255, 0, 0);
    linePaint.setStrokeWidth(3);
    linePaint.setDither(true);
    linePaint.setStyle(Style.FILL);
    linePaint.setAntiAlias(true);
    linePaint.setStrokeJoin(Paint.Join.ROUND);
    linePaint.setStrokeCap(Paint.Cap.ROUND);

}

public void addPoint(GeoPoint point) {
    populate();
    points.addElement(point);

}

//public void setProjection(Projection projection) {
//   this.projection = projection;
// }

public void draw(Canvas canvas, MapView view, boolean shadow) {
    populate();
    int size = points.size();
    Point lastPoint = new Point();
    if(size == 0) return;
    view.getProjection().toPixels(points.get(0), lastPoint);
    Point point = new Point();
    for(int i = 1; i<size; i++){
       view.getProjection().toPixels(points.get(i), point);
        canvas.drawLine(lastPoint.x, lastPoint.y, point.x, point.y, linePaint);
        lastPoint = point;

    }
}

@Override
protected OverlayItem createItem(int arg0) {
    // TODO Auto-generated method stub
    return null;
}

@Override
public int size() {
    // TODO Auto-generated method stub
    return 0;
}
}

What would be the easiest way to implement adding markers for each GeoPoint?

Answers


Take a look at http://www.vtgroup.com/index.html#MapLocation and see if it answers your question.


Need Your Help

Copy directory to a remote machine using SFTP in java

java sftp

I need to copy a directory from my local machine to a remote machine via SFTP. I've done copying a file through JSCH API, but it doesn't work on directories. Any suggestions?

what is the framework using in Blender GUI?

frameworks blender

What is the framework using in Blender GUI?