【发布时间】:2020-05-27 12:12:24
【问题描述】:
我正在从 OpenLayers 3.15.0 更新到 6.3.1。 当我调用 map.addLayer 时,出现以下错误:
Uncaught TypeError: Cannot read property 'ol_uid' of undefined @
ecb://web/java/ol.js:1:23754
这是调用它的上下文:
function getMinZoom() {
var width = map.clientWidth;
return Math.ceil(Math.LOG2E * Math.log(width / 256));
}
//create wms layer
function addWMSLayer(url, attTxt, attHref, layer, format, server, res1, res2, res3, res4) {
initializeMap();
//tile source for load wms layers
var newRes1 = Number(getCalcResolutionSrv(res1));
var newRes2 = Number(getCalcResolutionSrv(res2));
var newRes3 = Number(getCalcResolutionSrv(res3));
var newRes4 = Number(getCalcResolutionSrv(res4));
var newWMSSource = new ol.source.TileWMS({
url: url,
params: {
'LAYERS': layer,
'FORMAT': format,
},
serverType: 'mapserver',
projection: projection
});
var minZoom = getMinZoom();
var newWmsLayer = new ol.layer.Tile({
extent: extent,
source: newWMSSource,
minResolution: newRes4,
maxResolution: newRes1,
zIndex: 0,
minZoom: minZoom
});
wmsResolution.push(Number(newRes1 - 0.00100));
wmsResolution.push(newRes2);
wmsResolution.push(newRes3);
wmsResolution.push(Number(newRes4 + 0.00100));
map.addLayer(newWmsLayer);
ECBJS.addNewWMSLayer(url, layer, newRes1, newRes2, newRes3, newRes4);
};
除了属性 zIndex 和 minZoom 之外,该函数与 3.15.0 中用于调用 addLayer 的函数相同。在 3.15.0 中它可以工作。
可能是什么问题?
更新
我基于 CefSharp 的 MinimalExample 创建了 MinimalExample 解决方案。您需要 Visual Studio 或 Rider 才能打开它。 https://github.com/tbremeyer/CefSharp.MinimalExample.git
目前在 MainWindows.xaml.cs 中的 CallWebSite 函数中对 EvaluateScriptAsync 的调用返回
Message = "Uncaught TypeError: Cannot read property 'ol_uid' of
undefined @ ecb://web/java/ol.js:1:23754"
Success = false
我希望它会返回
Message = ""
Success = true
【问题讨论】:
标签: javascript openlayers