我已經完成了在我的覆蓋圖上繪製線條,但是如何繪製自由泳?不是像線條和圓圈那樣固定的幾何體,而是隻畫出我想要的地方!?android地圖覆蓋手繪
我已經是:
public class OverlayMap extends Overlay {
private List<MapGeoLine> geoLines = new ArrayList<MapGeoLine>();
private GeoPoint geoFrom = null;
private GeoPoint geoTo = null;
@Override
public boolean onTouchEvent(MotionEvent motionEvent, MapView mapView) {
if(motionEvent.getAction() == MotionEvent.ACTION_DOWN){
geoFrom = mapView.getProjection().fromPixels((int)motionEvent.getX(),(int)motionEvent.getY());
}
if(motionEvent.getAction() == MotionEvent.ACTION_UP){
geoTo = mapView.getProjection().fromPixels((int)motionEvent.getX(),(int)motionEvent.getY());
}
if(geoFrom != null && geoTo != null){
geoLines.add(new MapGeoLine(geoFrom, geoTo));
}
return super.onTouchEvent(motionEvent, mapView);
}
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
if(geoLines.size() > 0){
Paint mPaint = new Paint();
mPaint.setStrokeWidth(2);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setAntiAlias(true);
Projection projection = mapView.getProjection();
Path path = new Path();
for(MapGeoLine line: geoLines){
Log.d("test", "p1: "+line.getFrom().getLatitudeE6()+ " ");
Log.d("test", "p2: "+line.getTo().getLatitudeE6()+ " ");
Point from = new Point();
Point to = new Point();
projection.toPixels(line.getFrom(), from);
projection.toPixels(line.getTo(), to);
path.moveTo(from.x, from.y);
path.lineTo(to.x, to.y);
}
canvas.drawPath(path, mPaint);
mapView.invalidate();
}
super.draw(canvas, mapView, shadow);
}
}
嘿,你能幫我實施嗎?我有一些問題,應該在實施前明確。請 –