在Swift中将注释从一个坐标点移动到另一个坐标点 [英] Moving annotation from one coordinate point to another in Swift
问题描述
这是转发.我尽我所能完成此任务,但未成功. 我有两个坐标点,而我要做的就是将注释从一个点移动到另一个点.
This is a repost. I tried all I could do to get this thing done but wasn't successful. I have two coordinate points and all I'm trying to do is moving an annotation from one point to another.
作为一种替代解决方案,我在 github 中找到了一个Obj-C项目为此,我在Swift和Obj-C之间建立了桥接连接,以完成此操作.但是对于仅移动注释,我不得不使用整个项目,但我发现这不是一个好的解决方案.
As an alternative solution, I found an Obj-C project in github which is very similar to this and I made a bridged connection between Swift and Obj-C to get this done. But for just moving annotation I had to use this whole project which I found is not a good solution.
成功实现这种功能的任何人(迅速)吗?
Anyone who was successful in implementing such functionality (in swift)?
推荐答案
如果使用MKPointAnnotation
作为基础,则可以访问coordinate
属性,该属性实际上定义为var
,例如
If you are using MKPointAnnotation
as base, you can access the coordinate
property, which is actually defined as var
, e.g.
var coordinate: CLLocationCoordinate2D
Apple MKPointAnnotation Documentation. Therefore, when changing the coordinate, your annotation will move to another location.
这篇关于在Swift中将注释从一个坐标点移动到另一个坐标点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!