gisviewer-vue3-arcgis 1.0.141 → 1.0.143
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/src/gis-map/gis-map.vue.mjs +32 -32
- package/es/src/gis-map/utils/components/sketch-tool.vue.mjs +2 -2
- package/es/src/gis-map/utils/components/sketch-tool.vue2.mjs +10 -10
- package/es/src/gis-map/utils/map-initializer.mjs +6 -6
- package/es/src/gis-map/utils/signal-control-area-controller/index.mjs +57 -57
- package/es/src/gis-map/utils/sketchView.d.ts +14 -14
- package/es/src/gis-map/utils/sketchView.mjs +167 -163
- package/es/src/gis-map/utils/sketchViewTool.d.ts +16 -16
- package/es/src/gis-map/utils/sketchViewTool.mjs +39 -39
- package/es/style.css +1 -1
- package/lib/src/gis-map/gis-map.vue.js +1 -1
- package/lib/src/gis-map/utils/components/sketch-tool.vue.js +1 -1
- package/lib/src/gis-map/utils/components/sketch-tool.vue2.js +1 -1
- package/lib/src/gis-map/utils/map-initializer.js +1 -1
- package/lib/src/gis-map/utils/signal-control-area-controller/index.js +1 -1
- package/lib/src/gis-map/utils/sketchView.d.ts +14 -14
- package/lib/src/gis-map/utils/sketchView.js +1 -1
- package/lib/src/gis-map/utils/sketchViewTool.d.ts +16 -16
- package/lib/src/gis-map/utils/sketchViewTool.js +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import Graphic from '@arcgis/core/Graphic.js';
|
|
1
2
|
import GraphicsLayer from '@arcgis/core/layers/GraphicsLayer';
|
|
2
3
|
import MapView from '@arcgis/core/views/MapView';
|
|
3
4
|
import SceneView from '@arcgis/core/views/SceneView';
|
|
4
|
-
import SketchViewModel from '@arcgis/core/widgets/Sketch/SketchViewModel';
|
|
5
5
|
import Sketch from '@arcgis/core/widgets/Sketch';
|
|
6
|
-
import
|
|
6
|
+
import SketchViewModel from '@arcgis/core/widgets/Sketch/SketchViewModel';
|
|
7
7
|
import * as turf from '@turf/turf';
|
|
8
8
|
interface sketchViewOptions {
|
|
9
9
|
/**
|
|
@@ -17,7 +17,7 @@ interface sketchViewOptions {
|
|
|
17
17
|
/**
|
|
18
18
|
* 绘制工具显示的元素
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
sketchVisibleElements?: {};
|
|
21
21
|
/**
|
|
22
22
|
* 绘制工具显示的位置
|
|
23
23
|
*/
|
|
@@ -28,7 +28,7 @@ interface sketchViewOptions {
|
|
|
28
28
|
* @type {boolean}
|
|
29
29
|
* @memberof sketchViewOptions
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
defaultSketchVisible?: boolean;
|
|
32
32
|
sketchViewModelItemSymbol?: {
|
|
33
33
|
polylineSymbol?: any;
|
|
34
34
|
polygonSymbol?: any;
|
|
@@ -45,7 +45,7 @@ declare type dimensionTypeFace = 'distance' | 'area' | 'angle' | null;
|
|
|
45
45
|
export default class sketchViewTool {
|
|
46
46
|
private viewer;
|
|
47
47
|
graphicsLayer: GraphicsLayer;
|
|
48
|
-
|
|
48
|
+
textGraphicsLayer: GraphicsLayer;
|
|
49
49
|
sketchViewModel: SketchViewModel;
|
|
50
50
|
sketch: Sketch;
|
|
51
51
|
options: sketchViewOptions;
|
|
@@ -78,12 +78,12 @@ export default class sketchViewTool {
|
|
|
78
78
|
dimensionType: dimensionTypeFace;
|
|
79
79
|
constructor(view: MapView | SceneView, options?: sketchViewOptions);
|
|
80
80
|
init(): void;
|
|
81
|
-
on(
|
|
82
|
-
onCreate(event: __esri.SketchCreateEvent,
|
|
81
|
+
on(callback?: (type: string, state: string, event: any) => void): void;
|
|
82
|
+
onCreate(event: __esri.SketchCreateEvent, callback?: (type: string, state: string, event?: any) => void): void;
|
|
83
83
|
onCreateToCancel(): void;
|
|
84
|
-
onUpdate(event: __esri.SketchUpdateEvent,
|
|
85
|
-
onDelete(event: __esri.SketchDeleteEvent,
|
|
86
|
-
|
|
84
|
+
onUpdate(event: __esri.SketchUpdateEvent, callback?: (type: string, state: string, event?: any) => void): void;
|
|
85
|
+
onDelete(event: __esri.SketchDeleteEvent, callback?: (type: string, state: string, event: any) => void): void;
|
|
86
|
+
addPolyline(paths: number[][][]): void;
|
|
87
87
|
createPolylineGraphic(paths: number[][], lineSymbol: any, attributes: any): Graphic;
|
|
88
88
|
createDom(): HTMLDivElement | undefined;
|
|
89
89
|
removeDom(): void;
|
|
@@ -145,8 +145,8 @@ export default class sketchViewTool {
|
|
|
145
145
|
*/
|
|
146
146
|
calculatePointHeading(path: number[][], direction?: string): number;
|
|
147
147
|
drawPolylinePoint(drawStartGraphic: __esri.Geometry, parentId: string, actions?: string): void;
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
updatePolylinePoint(drawStartGraphic: Graphic[]): void;
|
|
149
|
+
deletePolylinePoint(drawStartGraphic: Graphic[]): void;
|
|
150
150
|
/**
|
|
151
151
|
* 添加或者更新标记点
|
|
152
152
|
*
|
|
@@ -186,7 +186,7 @@ export default class sketchViewTool {
|
|
|
186
186
|
* 获取当前绘制的图形的长度
|
|
187
187
|
* @returns
|
|
188
188
|
*/
|
|
189
|
-
|
|
189
|
+
getDrawGraphicLength(): string | 0;
|
|
190
190
|
/**
|
|
191
191
|
* 获取两点的角度
|
|
192
192
|
*
|
|
@@ -204,7 +204,7 @@ export default class sketchViewTool {
|
|
|
204
204
|
* @returns
|
|
205
205
|
* @memberof sketchViewTool
|
|
206
206
|
*/
|
|
207
|
-
|
|
207
|
+
getBearing(startPoint: ITPoint, endPoint: ITPoint): number;
|
|
208
208
|
/**
|
|
209
209
|
* 获取两点的距离
|
|
210
210
|
* @param startPoint
|
|
@@ -243,11 +243,11 @@ export default class sketchViewTool {
|
|
|
243
243
|
/**
|
|
244
244
|
* 开启图层捕捉
|
|
245
245
|
*/
|
|
246
|
-
|
|
246
|
+
turnOnLayerSnap(): void;
|
|
247
247
|
/**
|
|
248
248
|
* 关闭图层捕捉
|
|
249
249
|
*/
|
|
250
|
-
|
|
250
|
+
turnOffLayerSnap(): void;
|
|
251
251
|
setDimensionType(Type: dimensionTypeFace): void;
|
|
252
252
|
/**
|
|
253
253
|
* 删除指定的图形
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("@arcgis/core/geometry/geometryEngine.js"),u=require("@arcgis/core/geometry/Polyline.js"),M=require("@arcgis/core/geometry/support/webMercatorUtils.js"),m=require("@arcgis/core/Graphic.js"),f=require("@arcgis/core/layers/GraphicsLayer"),b=require("@arcgis/core/widgets/Sketch"),L=require("@arcgis/core/widgets/Sketch/SketchViewModel"),D=require("@turf/turf");function g(d){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const e in d)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(d,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>d[e]})}}return t.default=d,Object.freeze(t)}const w=g(P),p=g(M),h=g(D),k={maxAllowedGraphics:0,GraphicsLayer:{},sketchVisibleElements:{},sketchPosition:"top-left",defaultSketchVisible:!0,sketchViewModelItemSymbol:{}},G={type:"simple-line",color:"#556DEA",width:2},S={type:"simple-fill",color:[227,139,79,.4],outline:{color:[255,255,255],width:1}};class T{constructor(t,e){this.isDraw=!1,this.drawStartGraphicId=null,this.drawPointGraphic=new Map,this.dimensionType=null,this.viewer=t,this.options={...k,...e},this.graphicsLayer=new f({...this.options.GraphicsLayer}),this.textGraphicsLayer=new f,this.viewer.map.layers.add(this.graphicsLayer),this.viewer.map.layers.add(this.textGraphicsLayer),this.init()}init(){this.sketchViewModel=new L({layer:this.graphicsLayer,view:this.viewer,updateOnGraphicClick:!0,polylineSymbol:G,polygonSymbol:S,...this.options.sketchViewModelItemSymbol});const t=this.findLayerById("TrafficToolMarkings"),e=[];t&&e.push({layer:t,enabled:!0}),this.sketch=new b({view:this.viewer,viewModel:this.sketchViewModel,layer:this.graphicsLayer,visible:this.options.defaultSketchVisible,snappingOptions:{enabled:!0,featureSources:e}}),this.sketch.visibleElements={...this.options.sketchVisibleElements},this.viewer.ui.add(this.sketch,this.options.sketchPosition);const i=this;this.viewer.on("pointer-move",function(s){const r={x:s.x,y:s.y};if(i.isDraw&&i.dimensionType=="distance"){i.tipsDom||(i.tipsDom=i.createDom());const o=i.getDrawGraphicLength();i.tipsDom.innerText=`${o}米`,i.tipsDom.style.left=`${r.x}px`,i.tipsDom.style.top=`${r.y+3}px`,i.tipsDom.style.pointerEvents="none"}})}on(t){const e=this;this.sketch.on("create",function(i){e.onCreate(i,t)}),this.sketch.on("update",function(i){e.onUpdate(i,t)}),this.sketch.on("delete",function(i){e.onDelete(i,t)}),this.sketch.on("redo",function(i){console.log("redo",i),t&&t("redo","complete",i)}),this.sketch.on("undo",function(i){console.log("undo",i),t&&t("undo","complete",i)})}onCreate(t,e){if(console.log("create",t),this.drawStartGraphicId||(this.drawStartGraphicId=new Date().getTime().toString()),t.graphic.getAttribute("id")||(t.graphic.setAttribute("type","draw"),t.graphic.setAttribute("id",this.drawStartGraphicId)),t.state==="start"&&t.graphic.geometry.type==="polyline"&&(this.isDraw=!0,this.drawStartGraphic=p.webMercatorToGeographic(t.graphic.geometry),this.dimensionType=="distance")){const i=this.getGeometryXY(this.drawStartGraphic,0),s=`${this.drawStartGraphicId}-start`;this.addOrUpdateMarkPoint("起点",i,s)}if(t.state==="active"&&t.graphic.geometry.type==="polyline"){const i=p.webMercatorToGeographic(t.graphic.geometry),s=this.drawStartGraphicId;this.dimensionType=="distance"&&(this.drawPolylinePoint(i,s),this.drawStartGraphic=i)}if(t.state==="complete"&&t.graphic.geometry.type==="polyline"&&this.dimensionType=="distance"){const i=this.getDrawGraphicLength(),s=`${this.drawStartGraphicId}-end`,r=p.webMercatorToGeographic(t.graphic.geometry),o=r.paths[0],n=this.getGeometryXY(r,o.length-1);this.addOrUpdateMarkPoint(`总长度:${i}米`,n,s),this.drawStartGraphic=null,this.removeDom(),this.isDraw=!1,this.drawStartGraphicId=null}t.state==="cancel"&&t.graphic.geometry.type==="polyline"&&this.onCreateToCancel(),e&&e("create",t.state,t.graphic)}onCreateToCancel(){this.removeDom(),this.isDraw=!1,this.drawStartGraphic=null;const t=this.drawStartGraphicId;this.drawPointGraphic.forEach((e,i)=>{new RegExp(`^${t}-`).test(i)&&(this.textGraphicsLayer.remove(e),this.drawPointGraphic.delete(i))}),this.drawStartGraphicId=null}onUpdate(t,e){console.log("update",t),this.updatePolylinePoint(t.graphics.filter(i=>i.geometry.type==="polyline")),e&&e("update",t.state,t.graphics)}onDelete(t,e){console.log("delete",t),this.deletePolylinePoint(t.graphics.filter(i=>i.geometry.type==="polyline")),e&&e("delete","complete",t.graphics)}addPolyline(t){const e=[],i={type:"draw",id:new Date().getTime().toString()};t.map(s=>{e.push(this.createPolylineGraphic(s,G,{...i}))}),this.graphicsLayer.addMany(e)}createPolylineGraphic(t,e,i){const s=new u({paths:[t]}),r=p.geographicToWebMercator(s);return new m({geometry:r,symbol:e,attributes:i})}createDom(){const t=document.createElement("div");t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.style.width="100px",t.style.height="80px",t.style.zIndex="999",t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center",t.style.color="#fff",t.style.fontSize="20px",t.style.fontWeight="bold",t.innerText="";const e=document.getElementsByClassName("esri-view-root");if(e.length>0)return e[0].appendChild(t),t}removeDom(){this.tipsDom&&(this.tipsDom.remove(),this.tipsDom=null)}sketchCreate(t,e){this.sketchViewModel.create(t,e)}sketchCancel(){this.sketchViewModel.cancel()}getCalculateDistance(t="meters"){const e=[];return this.graphicsLayer.graphics.map(i=>{i.geometry.type==="polyline"&&e.push(this.calculateDistance(i.geometry,t))}),e}getCalculateHeading(t="north"){const e=[];return this.graphicsLayer.graphics.map(i=>{i.geometry.type==="polyline"&&e.push(this.calculateHeading(i.geometry,t))}),e}getAllPolylineGraphicPath(t="meters"){const e=[];return this.graphicsLayer.graphics.map(i=>{i.geometry.type==="polyline"&&e.push({paths:p.webMercatorToGeographic(i.geometry).paths[0],distance:this.calculateDistance(i.geometry,t)})}),e}close(){this.sketch.visible=!1}show(){this.sketch.visible=!0}removeAll(){this.graphicsLayer.removeAll(),this.textGraphicsLayer.removeAll(),this.drawPointGraphic.clear()}calculateDistance(t,e="meters"){return w.geodesicLength(t,e)}calculateHeading(t,e="north"){const s=p.webMercatorToGeographic(t).paths[0];return this.calculatePointHeading(s,e)}calculatePointHeading(t,e="north"){const i={longitude:t[0][0],latitude:t[0][1]},s={longitude:t[t.length-1][0],latitude:t[t.length-1][1]},r=i.longitude,o=i.latitude,n=s.longitude,a=s.latitude,c=n-r,y=Math.sin(c)*Math.cos(a),x=Math.cos(o)*Math.sin(a)-Math.sin(o)*Math.cos(a)*Math.cos(c);let l=(Math.atan2(y,x)*(180/Math.PI)+360)%360;return e==="east"?l=(l+90)%360:e==="south"?l=(l+180)%360:e==="west"&&(l=(l+270)%360),l}drawPolylinePoint(t,e,i="add"){const s=t==null?void 0:t.paths[0],r=[];for(let o=0;o<s.length-1;o++){const n=s[o];r.push([...n]);const a={x:n[0],y:n[1]};if(o==0){i=="update"&&this.addOrUpdateMarkPoint("起点",a,`${e}-start`);continue}const c=`${e}-${o+1}`,y=this.getPointLength(r,"meters");this.addOrUpdateMarkPoint(`${y.toFixed(2)}米`,a,c)}if(i=="update"&&s.length>1){const o=this.getGeometryXY(t,s.length-1);r.push([o.x,o.y]);const n=this.getPointLength(r,"meters");this.addOrUpdateMarkPoint(`总长度:${n.toFixed(2)}米`,o,`${e}-end`)}}updatePolylinePoint(t){for(let e=0;e<t.length;e++){console.log(t[e]);const i=t[e].getAttribute("id"),s=p.webMercatorToGeographic(t[e].geometry);this.drawPolylinePoint(s,i,"update")}}deletePolylinePoint(t){var e;for(let i=0;i<t.length;i++){const s=t[i].getAttribute("id"),r=`${s}-start`,o=`${s}-end`,n=[r,o];(e=t[i].geometry)==null||e.paths[0].map((a,c)=>{n.push(`${s}-${c+1}`)}),n.map(a=>{const c=this.drawPointGraphic.get(a);c&&(this.textGraphicsLayer.remove(c),this.drawPointGraphic.delete(a))})}}addOrUpdateMarkPoint(t,e,i,s={}){if(this.drawPointGraphic.has(i)){const o=this.drawPointGraphic.get(i);this.textGraphicsLayer.remove(o);const n=this.createTextGraphic(t,e,{...s,id:i});this.drawPointGraphic.set(i,n),this.textGraphicsLayer.add(n);return}const r=this.createTextGraphic(t,e,{...s,id:i});this.drawPointGraphic.set(i,r),this.textGraphicsLayer.add(r)}getGeometryXY(t,e=0){const i=t==null?void 0:t.paths[0];return{x:i[e][0],y:i[e][1]}}createTextGraphic(t,e,i={}){return new m({geometry:{type:"point",x:e.x,y:e.y},symbol:{type:"text",text:t,color:"white",haloColor:"black",haloSize:"1px",xoffset:3,yoffset:3},attributes:{...i}})}getDrawGraphicLength(){return this.drawStartGraphic?this.calculateDistance(this.drawStartGraphic,"meters").toFixed(2):0}getAngle(t,e){const i=e.x-t.x,s=e.y-t.y;return Math.atan2(s,i)*180/Math.PI}getBearing(t,e){return h.bearing(h.point([t.x,t.y]),h.point([e.x,e.y]))}getPointLength(t,e="meters"){const i=new u({paths:[t]});return w.geodesicLength(i,e)}featureCollection(t){const e=h.featureCollection(t.map(s=>h.point([s.x,s.y])));return h.center(e)}midpoint(t,e){return h.midpoint(h.point([t.x,t.y]),h.point([e.x,e.y]))}getDirection(t,e){const i=e.x-t.x,s=e.y-t.y,o=Math.atan2(s,i)*180/Math.PI;return o>=-45&&o<=45?0:o>45&&o<=135?1:o>135||o<=-135?2:3}findLayerById(t){return this.viewer.map.findLayerById(t)}turnOnLayerSnap(){this.sketchViewModel.snappingOptions.enabled=!0}turnOffLayerSnap(){this.sketchViewModel.snappingOptions.enabled=!1}setDimensionType(t){this.dimensionType=t}remove(t){this.graphicsLayer.remove(t)}destroy(){var t,e;this.viewer.map.remove(this.graphicsLayer),this.viewer.map.remove(this.textGraphicsLayer),(t=this.sketch)==null||t.destroy(),(e=this.sketchViewModel)==null||e.destroy()}}exports.default=T;
|