在我的MapView
我可以点击地图以创建任意数量的点,并且这些点通过一条线连接,但我不想像这样在地图上绘制任何可能与另一条线相交的线
无论如何要获取线的坐标来检查新线是否会与其他线相交?
或者,如果其他人对如何检查这一点有任何建议,那也很棒
这是我绘制线条的绘制方法
@Override
public void draw(final Canvas canvas, final MapView mapView, final boolean shadow){
super.draw(canvas, mapView, shadow);
try{
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setDither(true);
paint.setColor(Color.RED);
paint.setStrokeWidth(3);
paint.setAlpha(100);
paint.setStyle(Style.STROKE);
Path path = new Path();
Point point1 = null;
boolean runOnce = false;
for(int i = 0;i<items.size();i++){
Point point = new Point();
mapView.getProjection().toPixels(items.get(i).mGeoPoint, point);
if(!runOnce)
{
path.moveTo(point.x, point.y);
point1 = new Point(point.x, point.y);
runOnce = true;
}
else
{
path.lineTo(point.x, point.y);
}
}
path.lineTo(point1.x, point1.y);
canvas.drawPath(path, paint);
path.lineTo(point1.x, point1.y);
canvas.drawPath(path, paint);
Paint paint2 = new Paint();
paint2.setAntiAlias(true);
paint2.setDither(true);
paint2.setColor(Color.RED);
paint2.setStrokeWidth(3);
paint2.setAlpha(20);
paint2.setStyle(Style.FILL);
Path path2 = new Path();
Point point2 = null;
boolean runOnce2 = false;
for(int i = 0; i < items.size(); i++)
{
Point point = new Point();
mapView.getProjection().toPixels(items.get(i).mGeoPoint, point);
if(!runOnce2)
{
path2.moveTo(point.x, point.y);
point2 = new Point(point.x, point.y);
runOnce2 = true;
}
else
{
path2.lineTo(point.x, point.y);
}
}
path2.lineTo(point2.x, point2.y);
canvas.drawPath(path2, paint2);
}catch(Exception e){
}
}