用户在MKMapView上创建一个框 [英] User creating a box on MKMapView

查看:61
本文介绍了用户在MKMapView上创建一个框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,希望用户能够在某个位置(例如停车场)周围拖曳一个盒子.我想不出让他们画画的好方法.我可以跟踪很长一段时间,并从接触点绘制MKPolygon,但是我希望它们能够跟踪停车场,然后获取拐角处的坐标值.

I have an app that I want the user to be able to dray a box around a location, say a parking lot. I can't figure out a good way to let them draw this. I can track a long press, and draw the MKPolygon from the touch points, but I would like them to be able to trace the parking lot, and then get the coordinate values for the corners.

我不知道如何执行此操作,我们将不胜感激.

I have no idea how to do this, and any help would be appreciated.

推荐答案

您可以尝试的一种稍有不同且可能更简单的方法是让用户使用可拖动的批注指定拐角.

A slightly different and probably easier approach you can try is to let the user specify the corners using draggable annotations.

要开始绘图",请放置两个(或更多)注释以表示框的角.确保使用实现setCoordinate:的注释类,使其可拖动.

To start "drawing", place two (or more) annotations to represent the corners of the box. Be sure to use an annotation class that implements setCoordinate: so it's draggable.

用户可以将其拖到所需的角上,并在完成后点击一些按钮,此时您可以使用注释坐标创建MKPolygon,然后删除注释.

The user can drag the corners where they want and tap some button when done at which point you can create the MKPolygon using the annotation coordinates and then remove the annotations.

或者,您可以在用户每次完成拖动注释(角)并单击某些按钮说完成"后重新创建MKPolygon.

Or, you can re-create the MKPolygon every time the user finishes dragging an annotation (corner) and the user taps some button to say "done" and then you can remove the annotations.

这篇关于用户在MKMapView上创建一个框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆