首页 / 浏览问题 / 云GIS / 问题详情
调用addFeatures报错
25EXP 2017年06月13日
开始运行时 LabelLayer 调用addFeatures 的时候报错,后续再调用就不报错了

初始化的地方:
    var strategy3 = new SuperMap.Strategy.GeoText();
        strategy3.style = {
            fontColor: "#1874CD",
            fontWeight: "bold",
            labelXOffset: 0,
            labelYOffset: 50,
            fontSize: "14px",
            fill: false,
            fillColor: "#FFFFFF",
            fontOpacity: 1,
            fillOpacity: 0,
            stroke: false,
            strokeColor: "#8B7B8B"
        };
        dongtailukiangLabelLayer = new SuperMap.Layer.Vector("LabelLayer", {
            strategies: [strategy3]
        });

调用的地方:
dongtailukiangLabelLayer.addFeatures([geotextFeature]);

错误信息:
Uncaught TypeError: Cannot read property 'getResolution' of null
    at initialize.getViewPortPxFromLonLat (eval at <anonymous> (http://test.zzz.cn/Scripts/SuperMap/libs/SuperMap-8.1.0-14126.js:3:1), <anonymous>:1:68128)
    at initialize.getLabelPxLocation (eval at <anonymous> (http://test.zzz.cn/Scripts/SuperMap/libs/SuperMap-8.1.0-14126.js:3:1), <anonymous>:1:488127)
    at initialize.getDrawnLabels (eval at <anonymous> (http://test.zzz.cn/Scripts/SuperMap/libs/SuperMap-8.1.0-14126.js:3:1), <anonymous>:1:486177)
    at initialize.a.drawFeatures (eval at <anonymous> (http://test.zzz.cn/Scripts/SuperMap/libs/SuperMap-8.1.0-14126.js:3:1), <anonymous>:1:497577)
    at initialize.a.addFeatures (eval at <anonymous> (http://test.zzz.cn/Scripts/SuperMap/libs/SuperMap-8.1.0-14126.js:3:1), <anonymous>:1:497235)

1个回答

请自行检查、调试代码。
getResolution是map或者图层或者Control的方法,检查dongtailukiangLabelLayer在报错是是否赋值、是否添加到map等。
1,780EXP 2017年06月13日
...