简体   繁体   English

OpenLayers MouseUp事件-鼠标仍然拖动地图

[英]OpenLayers MouseUp Event - Mouse Still Drags Map

I register a mouse up event with an open layers map and the event gets fired when I do a mouse up, but the map keeps moving with the mouse. 我在打开的图层地图上注册了一个鼠标向上事件,当我向上移动鼠标时会触发该事件,但是该地图随鼠标移动。 For some reason registering this event caused the map to keep panning after I do a mouse up. 由于某种原因,注册此事件会导致在我按下鼠标后地图继续平移。

Here is the function: 这是函数:

var refreshCities = function(evt) { 
                       console.log("refreshing cities list"); 
                    };

Here is the event registration: 这是活动注册:

CitiesDisplay.events.register("mouseup", null, refreshCities);

After I saw this problem I tested the other types of events ("mousedown", "click", ...) but they don't have the same problem. 看到此问题后,我测试了其他类型的事件(“ mousedown”,“ click”,...),但它们没有相同的问题。 I haven't found anything else online in solving this problem. 我没有在网上找到其他任何东西可以解决这个问题。 Thank you for any help. 感谢您的任何帮助。

I solved the problem. 我解决了问题。 I needed to be registering this type of event: "moveend". 我需要注册这种类型的事件:“ moveend”。 Here is what would be changed in the registration: 这是注册中将要更改的内容:

CitiesDisplay.events.register("moveend", null, refreshCities);

Now everything seems to work as normal. 现在一切似乎都正常了。 This link is what helped me most: http://dev.openlayers.org/docs/files/OpenLayers/Layer-js.html#OpenLayers.Layer.events 这个链接对我的帮助最大: http : //dev.openlayers.org/docs/files/OpenLayers/Layer-js.html#OpenLayers.Layer.events

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

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