简体   繁体   English

在Swift中更新注释坐标/位置

[英]Updating annotation coordinates/location in Swift

I queried a set of coordinates for users around me from Parse(PFGeoPoint) and I have created annotations for said locations/coordinates. 我从Parse(PFGeoPoint)向我周围的用户查询了一组坐标,并为上述位置/坐标创建了注释。 I will be updating the users location every 5 seconds and updating the location of the annotations, everything is working fine except for the fact that I'm having to remove and add annotations instead of them moving on their own similar to lyft, is there a way to do this in swift? 我将每5秒钟更新一次用户位置并更新注释的位置,一切正常,除了我必须删除并添加注释,而不是像lyft那样自己移动注释的事实之外,迅速做到这一点的方法? please reply, thank you!! 请回复,谢谢!!

Yes it is. 是的。 As I can see from your tags, you are using MKPointAnnotation , so you an access its coordinate property and update it as you wish. 从标记中可以看到,您正在使用MKPointAnnotation ,因此您可以访问其coordinate属性并根据需要进行更新。

var coordinate: CLLocationCoordinate2D  

So all you have to do is set it up like this: 因此,您要做的就是这样设置:

annotation.coordinate = newCoordinate

For more information, please look at Accessing the Annotation's Location . 有关更多信息,请参见访问注释的位置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM