简体   繁体   English

更新Google地图上的标记

[英]Update markers on google map

I want to do the following , I have say a server where it updates (adds/removes) "Locations" of markers , then when some one uses my app I want him to see the markers available, the question is ... what is the best way to deal with the updating thing ? 我要执行以下操作,我说一台服务器,该服务器在其中更新(添加/删除)标记的“位置”,然后当有人使用我的应用程序时,我希望他看到可用的标记,问题是...什么是处理更新事物的最佳方法是什么? I mean I don't want the app to redraw all the markers when 1 marker is removed and/or added because I might be having A LOT OF MARKERS and this would take some time when we are talking on real time basis 我的意思是我不希望该应用在删除和/或添加1个标记时重新绘制所有标记,因为我可能有很多标记,而当我们进行实时交谈时,这会花费一些时间

You could store a unique identifier in the database for each marker that gets set as the marker 'snippet' when it is created. 您可以在数据库中为创建的标记“片段”中设置的每个标记存储唯一的标识符。 By keeping a reference to the Collection of markers in the view you could then update the marker collection (searching for the snippet ID) based on the state of the database, removing or adding from the map as necessary. 通过在视图中保留对标记集合的引用,您可以根据数据库的状态更新标记集合(搜索代码段ID),并根据需要从地图中删除或添加。 This would avoid recreating all markers again. 这样可以避免再次创建所有标记。

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

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