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