我在谷歌地图上工作,我想在两点之间画一条线我使用了本网站用户问题中的以下代码,但它对我不起作用当我在内部删除此功能时,我有一个强制关闭类应用程序工作
但我需要它,因为我必须画线
我使用的代码如下:
class MyOverlay extends com.google.android.maps.Overlay {
GeoPoint [] geoPointsArray ;
// constructor
public MyOverlay(){
}
@Override
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);
Point p1 = new Point();
Point p2 = new Point();
Path path = new Path();
projection.toPixels(gP1, p1);
projection.toPixels(gP2, p2);
path.moveTo(p2.x, p2.y);
path.lineTo(p1.x,p1.y);
canvas.drawPath(path, mPaint);
}
}//内部类结束
我真的需要帮助,当我添加这个东西时,我被逼近了:S