javascript - OpenLayers 仅在鼠标移动结束后才具有重绘功能

标签 javascript openlayers

在这种情况下,我使用来自 OpenLayersMap 控件2.10.在 map 上我有基础层 这是具有自定义功能的 OpenLayers.Layer.OSMOpenLayers.Layer.Vector。现在,当我使用鼠标移动 map 时,以前不可见的功能将不会重绘,直到释放鼠标按钮。我在所有 OpenLayers 示例中都注意到了同样的问题。任何人都可以提供某种解决方法来改变这种行为吗?我想要实现的是在要素变得可见后立即绘制要素或始终绘制所有要素(我使用少量要素,因此 map 控制的性能并不重要)。

我目前的想法是处理 map 上的一些特定事件(如鼠标移动和单击)并强制要素重绘。

最佳答案

更新

SVG2 渲染器在 v2.11 中引入,然后出于可靠性原因在 v2.12 中立即弃用(参见 this pull request )。对于 OL >= 2.12,设置图层的 ratio 属性以使其在更宽的区域内呈现所有功能作为屏幕尺寸的比例。权衡是性能,如果您的用户将他们的 map “扔”到某个方向,他们将飞过这些要素,但此时他们可能希望有一些渲染延迟。

new OpenLayers.Layer.Vector("My Layer", {
    ratio: 2
});

原始答案

来自 http://lists.osgeo.org/pipermail/openlayers-dev/2011-March/007345.html :

the new OpenLayers.Renderer.SVG2 renderer does what you are requesting. It is available on trunk (and will be in 2.11). To use it, configure the renderers array for your OpenLayers.Layer.Vector like this:

new OpenLayers.Layer.Vector("My Layer", {
    renderers: ["SVG2", "VML", "Canvas"]
});

Or set it on the prototype:

OpenLayers.Layer.Vector.renderers = ["SVG2", "VML", "Canvas"];

Note that VML (used in IE6,7,8) and Canvas (used on Android devices) behave like Renderer.SVG and don't draw features while panning.

关于javascript - OpenLayers 仅在鼠标移动结束后才具有重绘功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4991999/

相关文章:

javascript - IE 6 以后添加 <option>

javascript - Facebook 帖子嵌入呈现但未显示

javascript - 如何在 openlayers 4 中设置点样式

javascript - Openlayers 文本标签

javascript - 如何在页面加载时放大当前位置

javascript - 当我添加更多 &lt;script&gt; 标签时会发生什么?

JavaScript 可以在 Firefox 中运行,但不能在 Chrome 中运行

c# - 从谷歌地图 v3 方向 api 的结果中获取纬度和经度?

javascript - OpenLayers JS - 如何区分用户 View 更改和编程 View 更改?

OpenLayers v 5.3.0 - 找回归因行为