首页 / 浏览问题 / 云GIS / 问题详情
用for openlayers 的测量工具 报错
9EXP 2019年07月21日
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

1个回答

1,255EXP 2019年07月21日
...