当openlayers的地图所在的div的尺寸发生变化后,鼠标滚轮缩放地图发生偏移问题以及地图变形问题解决

当地图的尺寸发生变化后,要调用map.updateSize()方法,强制使openlayers重新计算地图视口

updateSize()
Force a recalculation of the map viewport size. This should be called when third-party code changes the size of the map viewport.
强制重新计算地图的视口大小。此方法应该在第三方代码改变了地图视口的大小之后调用。比如我用vue,写了拖拽指令改变地图窗口的尺寸,导致了地图缩放偏移和长宽比失调

https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html#updateSize

posted @ 2023-02-08 10:06  echo_lovely  阅读(583)  评论(0编辑  收藏  举报