用for openlayers 的测量工具 报错

0 投票
function iClientMeaLine() {
    var interaction, vectorLayer, feature;
    var url = "http://support.supermap.com.cn:8090/iserver/services/map-world/rest/maps/World"; //服务访问的地址


    var source = new ol.source.Vector({ wrapX: false });
    vectorLayer = new ol.layer.Vector({
        source: source
    });
    map.addLayer(vectorLayer);
    interaction = new ol.interaction.Draw({
        source: source,
        type: "LineString"
    });
    interaction.on('drawstart', function (evt) {
        feature = evt.feature;
    });
    interaction.on('drawend', function () {
        var distanceMeasureParam = new SuperMap.MeasureParameters(feature.getGeometry());
        new ol.supermap.MeasureService(url, { measureMode: "" }).measureDistance(distanceMeasureParam, function (serviceResult) {
            layer.msg(serviceResult.result.distance + "m");
        });
    });

    map.addInteraction(interaction);

};

总是显示0m

  控制台报错Typeerror  :c is null

7月 21, 2019 分类:  106次浏览 | 用户: 可乐5 (9 分)

1个回答

0 投票
7月 21, 2019 用户: 27。 名扬四海 (1,102 分)
...