Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想让用户在地图上标记一些区域。这个区域应该是任何封闭的形状。例如用户可以画这样的东西:
在下一步中,我想计算这个形状的区域。我怎样才能做到这一点?
您可以使用MKPolygon.
MKPolygon
首先,您需要禁用地图视图上的用户交互,以便在您尝试绘制时它不会四处移动。接下来您可以使用UIResponder函数touchesBegan和touchesMoved。touchesEnded当您浏览这三个功能时,您可以记录用户按下的点。最后,您可以从您记录的这个点数组创建一个 MKPolygon。
UIResponder
touchesBegan
touchesMoved
touchesEnded