我在谷歌地图上工作。我想在 5 到 6 个节点之间创建一个路径,我的意思是在点之间画一条线。
以下类是绘图的内部类:
class MyOverlay extends Overlay{
public void draw(Canvas canvas, MapView mapv, boolean shadow){
super.draw(canvas, mapv, shadow);
Paint mPaint = new Paint();
mPaint.setDither(true);
mPaint.setColor(Color.RED);
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
mPaint.setStrokeJoin(Paint.Join.ROUND);
mPaint.setStrokeCap(Paint.Cap.ROUND);
mPaint.setStrokeWidth(2);
GeoPoint gP1 = new GeoPoint(19240000,-99120000);
GeoPoint gP2 = new GeoPoint(37423157, -122085008);
GeoPoint gP3 = new GeoPoint(20000000 , -50000000) ;
GeoPoint[] G = new GeoPoint[3] ;
G[1] = gP1 ;
G[2] = gP2 ;
G[3] = gP3 ;
Point p1 = new Point();
Point p2 = new Point();
Point p3 = new Point () ;
Path path = new Path();
projection.toPixels(gP1, p1);
projection.toPixels(gP2, p2);
projection.toPixels(gP3, p3) ;
//path.moveTo(p2.x, p2.y);
//path.lineTo(p1.x,p1.y);
//path.lineTo(p3.x, p3.y) ;
//canvas.drawLines(pts , mPaint) ;
canvas.drawPath(path, mPaint);
}
}
这两行代码是onCreate()
外部类中方法的代码:
projection = mapView.getProjection();
mapOverlays.add(new MyOverlay());