javascript - 添加功能之前的 OpenLayers 拟合
问题描述
问题:开放图层适合地图,并且只有在添加功能(视觉上)之后,我该如何避免这种情况?
我在做这个
第 1 步 - 创建功能
var feature = new ol.Feature({...});
第 2 步 - 将它们添加到源
source.addFeature(feature);
第 3 步 - 像这样安装
view.fit(source.getExtent(), { duration: 1000 });
但视觉上显示步骤 3 -> 步骤 1 -> 步骤 2
我想做第 1 步 -> 第 2 步 -> 第 3 步(按代码顺序)
解决方案
您可以尝试适应视图addfeature
source.on('addfeature', function() {
view.fit(source.getExtent());
});
推荐阅读
- javascript - 如果 Angular 数据表中的数量 <1,如何选中复选框?我应该写一个函数吗?
- react-native - 反应原生嵌套堆栈导航返回
- eclipse - 如何在 Eclipse 比较视图中更改颜色
- powershell - 将文档写入 Domino 数据库的 Powershell 脚本
- python - Python - openpyxl wb.save() 抛出 TypeError
- arrays - 将字符串添加到空数组会给出“NAN”
- sql - 同一列的多个 LEFT JOINS
- angularjs - 不使用 acquireTokensilent 获取令牌,但使用 acquireTokenpopup Msal-browser 获取令牌
- azure - 如何正确配置 Azure DNS 以将所有流量路由到 CDN 配置文件
- javascript - 如何将回调函数(带有http请求)从父组件传递到Angular中的子组件