缩放事件侦听器之前的Javascript OpenLayers [英] Javascript OpenLayers before zoom event listener
问题描述
我试图将OpenLayers设置为在缩放开始之前不显示矢量层,并使其在缩放结束后重新出现.我已经像这样建立了变焦端部分:
I am trying to set up OpenLayers to not display the vector layer just before a zoom starts and make it reappear after a zoom ends. I have the zoom ends part already established like this:
map = new OpenLayers.Map('map_element', { eventListeners: { "zoomend": mapEvent}});
function mapEvent(event) {
if(event.type == "zoomend") {
hide_vector_layer();
}
}
但是在文档中开始放大时,我看不到任何类型的事件侦听器.有一个"movestart",涵盖了移动,平移和缩放.不幸的是,我不能使用"movestart",因为我不希望该图层在平移过程中消失.您会认为会有一个"zoomstart",因为会有一个"zoomend".
But I don't see any kind of event listener for the start of a zoom in the documentation. There is a "movestart" which covers moving, panning, and zoom. Unfortunately, I can't use the "movestart" one, because I don't want the layer to disappear during a pan. You would think there would be a "zoomstart", as there is a "zoomend".
之所以尝试这样做,是因为我不喜欢将Google Maps用作基础层时矢量层如何以不同的速率缩放.看起来不对,即使缩放完成后它们落在正确的位置,看起来所有功能也不正确.
The reason I am trying to do this, is because I don't like how the vector layer zooms at a different rate when using Google Maps as a base layer. It looks wrong, looks like all the features are inaccurate, even though they land in the right place after the zoom is complete.
有什么建议吗?
推荐答案
为此,您应该覆盖OpenLayers.Map的moveTo和moveByPx方法,以消除除缩放之外的任何动作的movestart事件触发.
For this purpose you should override moveTo and moveByPx methods of OpenLayers.Map for eliminate movestart event triggering for any actions except zooming.
这篇关于缩放事件侦听器之前的Javascript OpenLayers的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!