在运行时将maxZoom选项更改为ol.View,在angular-openlayers-directive中 [英] Change maxZoom option in runtime to ol.View in angular-openlayers-directive
问题描述
我发布了此问题以使用openlayers3在运行时更改maxZoom,并且效果很好:
I posted this question to change maxZoom in runtime using openlayers3 and that works perfect:
map.setView(new ol.View({
zoom: 10,
maxZoom: 17,
minZoom: 10,
}));
但是,我试图使用 angular-openlayers-directive 集成此解决方案并且地图消失了.这里 柱塞演示失败 .我尝试创建新指令,但也没有用.
However, im trying to integrate this solution using the angular-openlayers-directive and the map is disappearing. Here a Plunker demo failing. I tried creating new directive and also didn't work.
olData.getMap().then(function(map){
map.setView(new ol.View({
zoom: 11,
maxZoom: 11,
minZoom: 0,
}));
});
任何有关如何集成此功能以及是否可以在Plunker演示中使之工作的建议都是很好的.
Any suggestions on how to integrate this and if you could make it work in the Plunker demo would be great.
推荐答案
请参见ol.View
对象的文档
如果在创建ol.View
对象时未给出中心选项,则将其视为undefined
.如果它的undefined
则将不获取层源.在$scope.changeZoom()
中,方法中心未定义,因为在创建时未提供它.由于此地图对象未正确加载.
If center option is not given while creating ol.View
object it is taken as undefined
. If its undefined
then layer sources will not be fetched..In $scope.changeZoom()
method center was undefined since it was not provided while creating. Because of this map object was not loaded correctly.
修复
olData.getMap().then(function(map){
map.setView(new ol.View({
center: ol.proj.transform([37.41, 8.82], 'EPSG:4326', 'EPSG:3857'),
zoom: 11,
maxZoom: 11,
minZoom: 0,
}));
});
我给了一些随机坐标作为中心. 请参见有效的插件代码 此处
I have given some random coordinates as center. See the working plunk code here
这篇关于在运行时将maxZoom选项更改为ol.View,在angular-openlayers-directive中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!