From d74b495736f0c04522ec54274b70fed0ded2878d Mon Sep 17 00:00:00 2001
From: zhongrj <646384940@qq.com>
Date: Tue, 27 Jun 2023 11:30:06 +0800
Subject: [PATCH] 任务新增导出

---
 public/map/controls/toolbar/tools/MeasureLineTool.js |   90 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 90 insertions(+), 0 deletions(-)

diff --git a/public/map/controls/toolbar/tools/MeasureLineTool.js b/public/map/controls/toolbar/tools/MeasureLineTool.js
new file mode 100644
index 0000000..672b244
--- /dev/null
+++ b/public/map/controls/toolbar/tools/MeasureLineTool.js
@@ -0,0 +1,90 @@
+/**
+ * 线测量工具
+ * @author 温杨彪 2015-9-13
+ **/
+define([
+	"dojo/_base/declare",
+	"controls/toolbar/tools/DrawBaseTool",
+	"esri/toolbars/draw",
+	"dojo/dom-style",
+	"dijit/TooltipDialog",
+	"dijit/popup",
+	"esri/geometry/geometryEngine",
+	"dojo/dom",
+	"base/utils/RendererUtil",
+	"esri/graphic",
+	"esri/geometry/geodesicUtils",
+	"esri/units"
+], function(
+	declare,
+	DrawBaseTool,
+	Draw,
+	domStyle,
+	TooltipDialog,
+	popup,
+	geometryEngine,
+	dom,
+	RendererUtil,
+	Graphic,
+	geodesicUtils,
+	Units
+) {
+	var RL = declare([DrawBaseTool], {
+		_lineresulttooltip: null,
+		graphic: null,
+		_symbol: null,
+		constructor: function(args) {
+			this._normalIconClass = "tool-measureline-normal";
+			this._overIconClass = "tool-measureline-over";
+			this._selectedIconClass = "tool-measureline-select";
+			this._drawType = Draw.POLYLINE;
+			this.tooltip = "量距离";
+			this._symbol = RendererUtil.createSymbol({
+				type: "SimpleLineSymbol",
+				width: 2,
+				color: "#FD8044"
+			});
+		},
+		postCreate: function() {
+			this.inherited(arguments);
+			this._isDrawOnece = false;
+			this._lineresulttooltip = new TooltipDialog({
+				id: '_lineresulttooltip',
+				content: "<span id='measurelineresultspan'>测量结果:</span>"
+			});
+		},
+		onDrawEnd: function(geom) {
+			this.inherited(arguments);
+			geom.spatialReference.wkid = 4326;
+			var results = geodesicUtils.geodesicLengths([geom], Units.METERS);
+			var result = results[0];
+			if(result > 1000) {
+				dom.byId("measurelineresultspan").innerHTML = "测量结果:" + (result / 1000).toFixed(3) + "公里";
+			} else {
+				dom.byId("measurelineresultspan").innerHTML = "测量结果:" + result.toFixed(0) + "米";
+			}
+			if(this.graphic != null) {
+				this.graphic.setGeometry(geom);
+			} else {
+				this.graphic = new Graphic(geom, this._symbol);
+				this.map.graphics.add(this.graphic);
+			}
+		},
+		activate: function() {
+			this.inherited(arguments);
+			dijit.Tooltip.defaultPosition = ["below"];
+			popup.open({
+				popup: this._lineresulttooltip,
+				around: this.domNode
+			});
+			dom.byId("measurelineresultspan").innerHTML = "测量结果:";
+		},
+		deactivate: function() {
+			this.inherited(arguments);
+			popup.close(this._lineresulttooltip);
+			this.map.graphics.remove(this.graphic);
+			this.graphic = null;
+		},
+	});
+	return RL;
+});
\ No newline at end of file

--
Gitblit v1.9.3