检查MKPolyline是否与MKPolygon相交 [英] Check if MKPolyline intersects MKPolygon
问题描述
我试图找出MKPolyline
在地图上是否与MKPolygon
相交.目前,我对此的唯一想法是通过直线并在每个点上进行测试(如果它位于多边形中).更确切地说,我正在尝试测试MKUserLocation
和地图上的目标之间是否没有任何MKPolygon
(因此MKUserLocation
可以看到该目标).
I'm trying to figure out if a MKPolyline
intersects an MKPolygon
on map. Currently the only idea I have about this is to go through the line and test on every point if it is located in polygon. More exactly, I'm trying to test if there aren't any MKPolygon
between MKUserLocation
and an objective on map (so MKUserLocation
can see that objective).
关于如何执行此操作的任何更实际的想法?如果没有,如何将MKPolyLine转换成很多点?
Any more practical idea about how to do this? If not, how to transform the MKPolyLine into a lot of points?
推荐答案
它们都符合MKOverlay协议.您可以使用在名为boundingMapRect的协议上定义的属性,并在称为intersectsMapRect的协议定义的方法上使用.这里有更多信息:
They both conform to the MKOverlay protocol. You can use the property defined on the protocol called boundingMapRect, and use it on a protocol-defined method called intersectsMapRect. More info here:
这篇关于检查MKPolyline是否与MKPolygon相交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!