Android I add a path ( line by entering two location ) this code is done in my HelloOverlayItem class ! the problem is when i put this method no overlay items appear just the path and when i remove it the overlay items appear her is the method
enter code here
public void draw(android.graphics.Canvas canvas, MapView mapView, boolean shadow)
{
GeoPoint p = new GeoPoint((int) (29.98703241482666 * 1E6), (int) ( 31.439915891647359 * 1E6));
GeoPoint p2=new GeoPoint((int) (29.987107515335083 * 1E6), (int) ( 31.43912136554718 * 1E6));
//GeoPoint p3 = new GeoPoint((int) (29.98703241482666 * 1E6), (int) ( 31.439915891647359 * 1E6));
//GeoPoint p4=new GeoPoint((int) (29.987107515335083 * 1E6), (int) ( 31.43912136554718 * 1E6));
// Let's assume you've assigned values to these two GeoPoints now.
Projection projection = mapView.getProjection();
Point startingPoint = projection.toPixels(p, null);
Point endingPoint = projection.toPixels(p2, null);
//point startingPoint1 = projection.toPixels(p3, null);
//Point endingPoint2 = projection.toPixels(开发者_开发知识库p4, null);
// Create the path containing the line between the two points.
Path path = new Path();
path.moveTo(startingPoint.x, startingPoint.y);
path.lineTo(endingPoint.x, endingPoint.y);
// Setup the paint. You'd probably do this outside of the draw() method to be more efficient.
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setColor(Color.RED);
// mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
// mPaint.setStrokeJoin(Paint.Join.ROUND);
//mPaint.setStrokeCap(Paint.Cap.ROUND);
//mPaint.setStrokeWidth(2);
// Can set other paint characteristics, such as width, anti-alias, color, etc....
// Draw the path!
canvas.drawPath(path, paint);
}
You've overriden the superclass draw() method. You need to call it in your method with:
super.draw(canvas, mapView, shadow);
精彩评论