在这种情况下,我使用来自 OpenLayers 的 Map
控件2.10.在 map 上我有基础层
这是具有自定义功能的 OpenLayers.Layer.OSM
和 OpenLayers.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 yourOpenLayers.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/