openlayers-3 - 如何以编程方式缩放 map Openlayers 3?

标签 openlayers-3

我想在标记周围画一个正方形。如果我画一个大正方形, map 应该自动缩小,以便我们可以完整地看到正方形。如果我画一个小正方形, map 应该自动放大以完全显示正方形。

In this image I have drawn small square so we can see the square completely

In this image I have drawn a larger square, Since the map is not zooming out we cannot see the square sides

最佳答案

ol.View在 openlayers 3 文档中。有一个功能setZoom(zoom) .

所以如果你的 map 变量是 map , 放大使用 map.getView().setZoom(map.getView().getZoom() + 1);并缩小使用 map.getView().setZoom(map.getView().getZoom() - 1);

关于openlayers-3 - 如何以编程方式缩放 map Openlayers 3?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40905127/

相关文章:

typescript - 如何集成 openlayers 3 转换扩展

javascript - openlayers crossOrigin参数使图层消失

javascript - 添加图像和动画线串

internet-explorer-11 - Openlayers 添加了 Internet Explorer 内存问题的功能

javascript - Openlayers 3 无法删除功能

javascript - 如何通过 OpenLayers 绘制一条动画线来说明两点之间的流动?

javascript - 标记或叠加移动动画在 openlayers 3 中平滑移动

javascript - BNG 中的 Open Layers 3 鼠标位置检测不起作用

javascript - OpenLayer 功能中属性 "population"的用途是什么?

openlayers-3 - 在 OpenLayers 3.5.0 中使用 CSS 更改控件样式