简体   繁体   English

Openlayers 3 map,如何在没有焦点的情况下刷新

[英]Openlayers 3 map, how refresh without having focus

I have two similar problems with an Openlayers 3 map.我对 Openlayers 3 map 有两个类似的问题。 They both pertain to making the map refresh/redraw when it doesn't have focus;它们都与 map 在没有焦点时刷新/重绘有关; ie when the mouse is not over it.即当鼠标不在它上面时。

1) I show an outline of a country when the mouse is over it, but it becomes transparent when the mouse moves off. 1)当鼠标悬停在一个国家的轮廓上时,它会显示一个国家的轮廓,但当鼠标移开时它会变得透明。 However, if the country is at the edge of the map view and I move the mouse off that edge of the map, the country stays outlined, because the map never sees the mouse over another area outside the country.但是,如果该国家位于 map 视图的边缘,并且我将鼠标移出 map 的边缘,则该国家将保持轮廓,因为 map 从未在该国家以外的另一个区域看到鼠标。

2) When I click on a country, it becomes permanently highlighted (ie a layer becomes visible). 2)当我点击一个国家时,它会永久突出显示(即图层变得可见)。 I have a button off the map that when clicked resets all the layers to transparent.我在 map 上有一个按钮,单击该按钮会将所有图层重置为透明。 When I click the button, nothing happens until I move the mouse back over the map, at which point the change becomes apparent and the layers disappear.当我单击按钮时,什么都没有发生,直到我将鼠标移回 map 上,此时变化变得明显并且层消失了。

Is there a way to force the map to update when the mouse is not over it?有没有办法在鼠标不在 map 上时强制更新它?

I have tried several options: map.redraw() , layer.redraw() , source.refresh() , map.refresh() , layer.refresh() , source.refresh() , document.getElementById("map").focus() and anything else I can find suggested to force a map to refresh, but none of them work until the mouse is moved over the map.我尝试了几个选项: map.redraw()layer.redraw() , source.refresh( source.refresh()map.refresh()layer.refresh() source.refresh()document.getElementById("map").focus()和我能找到的任何其他建议强制 map 刷新,但在鼠标移到 map 上之前,它们都不起作用。

My mistake, simple bug.我的错误,简单的错误。 Failed to update the style directly, assuming another routine was handling it.无法直接更新样式,假设另一个例程正在处理它。

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

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