OpenLayers:放大或缩小后,重新显示被破坏的功能 [英] OpenLayers: destroyed features reappear after zooming in or out

查看:349
本文介绍了OpenLayers:放大或缩小后,重新显示被破坏的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个OpenLayers + Bing映射应用程序,其中显示了危险废物的场所.用户可以单击链接在地图上切换站点的子站点.

I have an OpenLayers + Bing mapping application that shows hazardous waste sites. A user can click a link to toggle a site's subsites on the map.

通过调用层上的destroyFeatures()来关闭子站点(在Vector层上的点)时,它们会消失.但是,如果我在地图上放大或缩小,则某些子站点会重新出现.移动地图,仅缩放时不会发生这种情况.

When I toggle the subsites off (which are points on a Vector layer) by calling destroyFeatures() on the layer, they disappear as expected. However, if I zoom in or out on the map, certain of the subsites reappear. This doesn't happen when moving the map, just zooming.

神秘重现的是重合的站点,即两个坐标完全相同的站点.两者都被摧毁,并且都重新出现.

The ones that mysteriously reappear are coincident sites, i.e. two sites with exact same coordinates. Both get destroyed, and both reappear.

为什么这些东西会从图层中销毁,然后在缩放时重新出现?

Why would these get destroyed from the layer, then reappear when zooming?

(OpenLayers版本为2.11)

(OpenLayers version is 2.11)

推荐答案

尝试一下,它对我有用

layer.removeAllFeatures();
layer.destroyFeatures();//optional
layer.addFeatures([]);

这篇关于OpenLayers:放大或缩小后,重新显示被破坏的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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