根据服务器数据(纬度和经度)在MKMapView中移动注释 [英] Moving annotations in MKMapView according to server data (latitude and longitude)

查看:65
本文介绍了根据服务器数据(纬度和经度)在MKMapView中移动注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用中,我通过按特定间隔从服务器获取其他人的位置(纬度和经度)来显示其他人的位置.

In my app I am showing location of some other person by getting their location (latitude and longitude) from server at particular interval.

获取后,我必须删除所有注释并根据服务器数据删除新的注释.

After getting I have to remove all annotations and drop new annotations based on the server data.

但是它看起来效率很低,因为当我们以前存在相同用户的注释时,即使我要删除并添加相同的用户注释,也是如此.

But it looks very inefficient as when we have the annotation for the same user previously exists even then I'm removing and adding the same user annotation.

所以我想知道我们可以将MKA注释从一个坐标移动到另一个坐标吗?我尝试了"setCoordinate"属性,但无法成功实现.

So I want to know can we move the MKAnnotation from one coordinate to other? I have tried "setCoordinate" property but unable to succesfuly implement it.

它也不是触摸并拖动"的那种.当应用从服务器获取数据(纬度和经度)时,注释会自行移动.

Also it is not "touch and drag" kind. The annotations move itself when the app get data (latitude and longitude) from server.

推荐答案

为什么会有性能问题?你把它弄干净了吗? 您只是在更改对象数组,甚至没有创建新实例.

Why is that a performance problem? Have you mesaured it? You're just changing an array of objects, not even creating new instances.

MapView上的AnnotationViews无论如何都将被重用.对此应该没有任何问题.

The AnnotationViews on the MapView will be reused anyway. There shouldn't be any problems with that.

这篇关于根据服务器数据(纬度和经度)在MKMapView中移动注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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