我现在已经几多边形如下图所示,与下面的代码Android查找多边形交集?
CustomPolygon customPolygon= data.getCustomPolygonList().get(i);
Path path = new Path();
path.setFillType(Path.FillType.EVEN_ODD);
for(int n=0;n<customPolygon.getCorrdinateList().size();n++)
{
GeoPoint sector1 = new GeoPoint((int)(customPolygon.getCorrdinateList().get(n).getLatitude()*1e6), (int)((customPolygon.getCorrdinateList().get(n).getLongitude())*1e6));
if(n==0){
mapView.getProjection().toPixels(sector1, point1_draw);
path.moveTo(point1_draw.x,point1_draw.y);
}else
{
mapView.getProjection().toPixels(sector1, point1_draw);
path.lineTo(point1_draw.x,point1_draw.y);
}
}
path.close();
canvas.drawPath(path, paint);
我现在就盘算上被绘制到我的MapView我怎么知道如果ONTAP按钮与任何多边形相交。例如,如果它与其中一个多边形相交,则会显示一条消息显示当前的多边形。
我被困在叠加层的ontap部分。
@Override
public boolean onTap(GeoPoint p, MapView) {
Point point1_draw = new Point();
mapView.getProjection().toPixels(p, point1_draw);
for (int i =0;i<data.getCustomPolygonList().size();i++)
{
CustomPolygon customPolygon= data.getCustomPolygonList().get(i);
for(int n=0;n<customPolygon.getCorrdinateList().size();n++)
{
}
}
return true;
}
你有一个类型:'getCorrdinateList'应该是'getCoordinateList'。要修复它,请点击它并在大多数IDE中按下Ctrl-Shift-R。 – 2012-07-30 08:33:30
哦错字,这是一个用于存储多边形坐标的自定义类 – ericlee 2012-07-30 08:49:50