javascript - 类型错误:mapLayers[i].getSource 不是函数
问题描述
现在我用 ol-layerswitcher (walkermatt) 构建了一个开放层地图。该地图在其他版本中使用 OL 6 和 Firefox。https://www.kweimar.de/TB_MapOS.html(侧边栏(onClick)中的链接仅适用于firefox。)在https://www.kweimar.de/TB_MapOS1.html中是错误Uncaught TypeError : mapLayers[i].getSource 不是函数 因为该函数在其他版本中工作,我认为还有另一个问题。关键是地图只能在我的帐户中使用。这是部分:
var select = new ol.interaction.Select();
map.addInteraction(select);
var selectedFeatures = select.getFeatures();
var infoBox = document.getElementById('sidebar-list');
map.on('moveend', function(e) {
infoBox.innerHTML = "";
var info = [];
var mapLayers = map.getLayers().getArray();
for(var i=1;i<7 ; i++) {
if (mapLayers[i].getVisible()==true) {
var Source = mapLayers[i].getSource();
var extent = map.getView().calculateExtent(map.getSize());
Source.forEachFeatureIntersectingExtent(extent, function(feature) {
nam = feature.get('name')
nummer = feature.get('nummer');
listed = feature.get('listed');
// searchString="Llan";
if(nam !== null && nam.toUpperCase().match(searchString.toUpperCase())){
info.push([nam,listed,nummer]);
}
});
} // ende if
} // ende for
谢谢
解决方案
推荐阅读
- amazon-web-services - Amazon SNS:创建 AWS Lambda API 网关,如何确认订阅
- php - 带有 firebird 和 php 的 Web 服务
- laravel - Laravel:更改数据库中时间戳的名称
- c++ - 是shared_future
条件变量的合法替代品? - python - Numpy 全局保持维度
- javascript - 什么是“PropTypes.oneOf”的 TypeScript 等效项(将变量限制为值的子集)
- google-cloud-platform - 如何让 glusterfs 在集群升级中存活下来
- angular - Datepicker (matCalendar) angular2 应该在滚动页面时移动
- scala - 如何在 slick 中创建多个主键?
- ubuntu - Portaudio 选择用于捕获的输入设备