首页 > 解决方案 > asp.net 和 OpenLayers4:无法在弹出控件中读取 null 的属性“0”

问题描述

我正在开发一个使用 asp.net、c# 和 openlayers4 处理地图的网站。地图代码写在单独的页面map.aspx中。ASPxPopupControl我在主页中显示此buildings.aspx页面。在地图页面中,我调用缩放到某个点 x,y 的方法。该代码已成功执行了数周。现在代码给了我这个错误:

 Uncaught TypeError: Cannot read property '0' of null  at ol.js:442
at Bn.k.qm (ol.js:442)
at Bn.b (ol.js:46)
at Bn.Sc.b (ol.js:49)
at Yc (ol.js:51)
at Bn.k.set (ol.js:51)
at Bn.k.We (ol.js:442)

这就是我所说的ol<script src="https://openlayers.org/en/v4.6.5/build/ol.js"></script>

导致错误的代码行

overlay.setPosition(ol.proj.transform(coordinate, 'EPSG:28191', 'EPSG:3857'));

overlay在哪里

var container = document.getElementById('popup');
   var overlay = new ol.Overlay({
        element: container,
        autoPan: true,
        autoPanAnimation: {
            duration: 250
        }
    });

当我从map.aspx页面运行代码时,它可以成功运行,但如果页面显示在ASPxPopupControl. 正如我之前所说,代码正在使用ASPxPopupControl.

标签: javascriptasp.netdevexpressopenlayers

解决方案


推荐阅读