依地面积量算为0.00平方米

0 投票

使用产品:iserver 8c 810 操作系统 win10 x64

数据类型:

问题详细描述:3D for plugin 开发,使用三维量算:依地面积量算,无论如何操作结果都为0。

//依地面积量测
function MeasurerTerrainArea() {
	var sceneControltool = parent.sceneControl;
	var SuperMap = parent.SuperMap;
	//设置控件的当前操作为面积量算
	var measureAreaAction = new SuperMap.Web.UI.Action3Ds.MeasureTerrainArea(sceneControltool);
	sceneControltool.set_sceneAction(measureAreaAction);

	//给面积量算事件和量算结束事件注册回调函数
	altitudeMode = 0;
	tag = "MeasureTerrainArea";
	sceneControltool.addEvent("measureArea", areaHandler);
	sceneControltool.addEvent("measureAreaFinished", areaFinishedHandler);
}
function areaHandler(dArea) {
	//量算过程中及时的显示量算信息
	//document.getElementById("MeasureInfo").innerHTML = "<div>" + "面积:" + dArea + "平方米" + "</div>";
	window.status = "面积:" + dArea + "平方米";
}

function areaFinishedHandler(dArea, region3d) {
	var unit = '平方米';
	if(dArea > 1000000) {
		unit = "平方千米";
		dArea = dArea / 1000000;
	}
	var text = '总面积:' + dArea.toFixed(2) + unit;
	//document.getElementById("MeasureInfo").innerHTML = "<div>" + text + "</div>";
	addGeometryToScene(region3d, tag);
	AddGeometryPoint(region3d);

	/*添加标注字体*/
	var point3D = region3d.get_innerPoint3D();
	addTextToScene(text, point3D, "MeasureArea");
	pan();
	$('#layerFormFour').contents().find('.tool-box ul li').siblings().removeClass('tool-ba');
}

//设置控件的当前操作为距离量算
function addGeometryToScene(geometry, tag) {
	var scenetool = parent.scene;
	var SuperMap = parent.SuperMap;
	var feature3D = new SuperMap.Web.Core.Feature3D();
	feature3D.set_geometry(geometry);
	var style3d = new SuperMap.Web.Core.Style3D();
	style3d.set_altitudeMode(altitudeMode);
	style3d.set_markerColor(new SuperMap.Web.Core.Color(255, 0, 255, 250));
	style3d.set_lineWidth(1.5);
	style3d.set_lineColor(new SuperMap.Web.Core.Color(255, 255, 0, 255));
	style3d.set_fillForeColor(new SuperMap.Web.Core.Color(255, 255, 0, 50));
	feature3D.set_style3D(style3d);
	scenetool.get_trackingLayer3D().add(feature3D, tag);
}

//量算结果加载到场景上
function addTextToScene(text, position, tag) {
	var scenetool = parent.scene;
	var SuperMap = parent.SuperMap;
	var feature3D = new SuperMap.Web.Core.Feature3D();
	var geoText3D = new SuperMap.Web.Core.GeoText3D();
	var textPart3D = new SuperMap.Web.Core.TextPart3D(text, position);
	geoText3D.addPart(textPart3D);
	feature3D.set_geometry(geoText3D);

	var style3d = new SuperMap.Web.Core.Style3D();
	style3d.set_altitudeMode(SuperMap.Web.Realspace.AltitudeMode.ABSOLUTE);

	var textStyle = new SuperMap.Web.Core.TextStyle3D();
	textStyle.set_outline(true);
	textStyle.set_foreColor(new SuperMap.Web.Core.Color(255, 255, 0, 255));
	textStyle.set_backColor(new SuperMap.Web.Core.Color(0, 0, 0, 255));
	textStyle.set_isSizeFixed(true);
	textStyle.set_fontScale(0.9);
	feature3D.set_textStyle3D(textStyle);
	feature3D.set_style3D(style3d);
	scenetool.get_trackingLayer3D().add(feature3D, tag);

}

1月 25, 2018 分类:  167次浏览 | 用户: 小灰 初出茅庐 (84 分)

1个回答

0 投票
您好,量算功能您可以参考插件客户端的示例:空间查询 - 量算。您可以先看下示例能否正常显示结果。

另外,您的版本可能过低,建议您安装900或者901版本的插件,然后重新试一下。
1月 25, 2018 用户: 张阳名 登峰造极 (5,392 分)
...