[英]Prevent interactions on OpenLayers map while animation is on action
I'm working on a web application that uses OpenLayers map. On this component, I get the properties from its parent, which are used to draw some icons on specified coordinates on the map, and since this takes a bit of a time, to cover that time, I'm using this animation:我正在开发一个使用 OpenLayers map 的 web 应用程序。在这个组件上,我从其父级获取属性,这些属性用于在 map 上的指定坐标上绘制一些图标,由于这需要一点时间,因此那个时候,我正在使用这个 animation:
map.getView().animate({ center: transform(latitude, longitude], 'EPSG:4326', 'EPSG:3857'), duration: 1000 })
I'm trying to find a solution to prevent any type of mouse interaction on the map, while this animation is in action (not finished).我试图找到一个解决方案来防止 map 上的任何类型的鼠标交互,而这个 animation 正在运行(未完成)。
To deactivate the interactions call a function like disableInteraction()
:要停用交互,请调用 function,例如disableInteraction()
:
const disableInteraction = () => {
map.getInteractions().forEach(i => {
i.setActive(false)
})
}
You can call enableInteractions()
when the animation stops (or whenever you need), to reactivate the interactions:您可以在 animation 停止时(或任何您需要的时候)调用enableInteractions()
来重新激活交互:
const enableInteractions = () => {
map.getInteractions().forEach(i => {
i.setActive(true)
})
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.