gisviewer-vue3-arcgis 1.0.95 → 1.0.96

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.
@@ -27,7 +27,7 @@ export default class SignalHoloFlow {
27
27
  private updateCountdown;
28
28
  /**
29
29
  * 在倒计时面板上写入倒计时时间
30
- * @param countdownCanvas 倒计时面板canvas
30
+ * @param canvas 倒计时面板canvas
31
31
  * @param rtStage 相位数据
32
32
  * @param rtStage.stageID 相位名
33
33
  * @param rtStage.stageRemainingTime 剩余时间
@@ -35,6 +35,8 @@ export default class SignalHoloFlow {
35
35
  * @param rtStage.stageYellowTime 黄灯时间
36
36
  */
37
37
  private drawCountdownText;
38
+ private drawCircle;
39
+ private ctxDraw;
38
40
  private updatePhaseLine;
39
41
  /**
40
42
  * 车道是否在通道中
@@ -1,12 +1,12 @@
1
- import * as c from "@arcgis/core/core/reactiveUtils";
2
- import { Point as d } from "@arcgis/core/geometry";
1
+ import * as d from "@arcgis/core/core/reactiveUtils";
2
+ import { Point as c } from "@arcgis/core/geometry";
3
3
  import p from "@arcgis/core/layers/FeatureLayer";
4
4
  import u from "../../stores/index.mjs";
5
5
  class f {
6
- constructor(a) {
7
- this.currentPhaseMap = /* @__PURE__ */ new Map(), this.countdownCanvasMap = /* @__PURE__ */ new Map(), this.lastDataTime = 0, this.isDeletingCanvas = !1, this.canvasWidth = 120, this.canvasHeight = 50, this.view = (a.type === "2d", a);
8
- const e = u.useAppDataStore;
9
- this.mapConfig = JSON.parse(JSON.stringify(e.mapConfig));
6
+ constructor(e) {
7
+ this.currentPhaseMap = /* @__PURE__ */ new Map(), this.countdownCanvasMap = /* @__PURE__ */ new Map(), this.lastDataTime = 0, this.isDeletingCanvas = !1, this.canvasWidth = 80, this.canvasHeight = 40, this.view = (e.type === "2d", e);
8
+ const a = u.useAppDataStore;
9
+ this.mapConfig = JSON.parse(JSON.stringify(a.mapConfig));
10
10
  }
11
11
  /**
12
12
  * 初始化相位线图层
@@ -16,19 +16,19 @@ class f {
16
16
  if (this.phaseLineLayer)
17
17
  this.phaseLineLayer.visible || (this.phaseLineLayer.visible = !0);
18
18
  else {
19
- const a = `${this.mapConfig.assetsRoot}/${this.mapConfig.phaseLineLayer}`, o = (await (await fetch(a)).json()).features.map((t, s) => ({
19
+ const e = `${this.mapConfig.assetsRoot}/${this.mapConfig.phaseLineLayer}`, n = (await (await fetch(e)).json()).features.map((s, t) => ({
20
20
  geometry: {
21
21
  type: "polyline",
22
- paths: [t.geometry.coordinates]
22
+ paths: [s.geometry.coordinates]
23
23
  },
24
24
  attributes: {
25
- ObjectID: s + 1,
26
- id: t.properties.id,
25
+ ObjectID: t + 1,
26
+ id: s.properties.id,
27
27
  color: "hide"
28
28
  }
29
29
  }));
30
30
  this.phaseLineLayer = new p({
31
- source: o,
31
+ source: n,
32
32
  geometryType: "polyline",
33
33
  objectIdField: "ObjectID",
34
34
  outFields: ["*"],
@@ -105,81 +105,97 @@ class f {
105
105
  }), this.view.map.add(this.phaseLineLayer);
106
106
  }
107
107
  }
108
- async handleSignalData(a) {
109
- const { crossId: e, lat: i, lon: o, rtStage: t, channelsConfig: s } = a;
110
- await this.updateCountdown(e, i, o, t), !(!this.phaseLineLayer || !s) && ((!this.currentPhaseMap.has(e) || this.currentPhaseMap.get(e) !== t.stagePhase) && await this.updatePhaseLine(
111
- e,
112
- t.channelsConfig,
113
- s
114
- ), this.currentPhaseMap.set(e, t.stagePhase));
108
+ async handleSignalData(e) {
109
+ const { crossId: a, lat: i, lon: n, rtStage: s, channelsConfig: t } = e;
110
+ await this.updateCountdown(a, i, n, s), !(!this.phaseLineLayer || !t) && ((!this.currentPhaseMap.has(a) || this.currentPhaseMap.get(a) !== s.stagePhase) && await this.updatePhaseLine(
111
+ a,
112
+ s.channelsConfig,
113
+ t
114
+ ), this.currentPhaseMap.set(a, s.stagePhase));
115
115
  }
116
116
  /**
117
117
  * 清除实时信号相关图层
118
118
  * */
119
119
  clearSignal() {
120
- this.phaseLineLayer && (this.phaseLineLayer.visible = !1), this.countdownWatchHandel && (this.countdownWatchHandel.remove(), this.countdownWatchHandel = void 0), this.countdownCanvasMap.forEach((a) => {
121
- this.view.container.removeChild(a.backgroundCanvas), this.view.container.removeChild(a.countdownCanvas);
120
+ this.phaseLineLayer && (this.phaseLineLayer.visible = !1), this.countdownWatchHandel && (this.countdownWatchHandel.remove(), this.countdownWatchHandel = void 0), this.countdownCanvasMap.forEach((e) => {
121
+ this.view.container.removeChild(e.backgroundCanvas), this.view.container.removeChild(e.countdownCanvas);
122
122
  }), this.countdownCanvasMap.clear();
123
123
  }
124
124
  /**
125
125
  * 获取显示倒计时的canvas
126
126
  * */
127
- async updateCountdown(a, e, i, o) {
127
+ async updateCountdown(e, a, i, n) {
128
128
  if (this.isDeletingCanvas)
129
129
  return;
130
- const t = this.countdownCanvasMap.get(a);
131
- if (t)
132
- this.drawCountdownText(t.countdownCanvas, o);
133
- else {
134
- const s = new d({
135
- longitude: i,
136
- latitude: e,
137
- z: 10
138
- }), n = this.view.toScreen(s);
139
- this.createCountdownCanvas((l) => {
140
- const h = l[0], r = l[1];
141
- h.style.left = n.x + "px", h.style.top = n.y + "px", r.style.left = n.x + "px", r.style.top = n.y + "px", this.countdownCanvasMap.set(a, {
130
+ const s = this.countdownCanvasMap.get(e);
131
+ if (s)
132
+ this.drawCountdownText(s.countdownCanvas, n);
133
+ else
134
+ try {
135
+ const t = new c({
136
+ longitude: i,
137
+ latitude: a,
138
+ z: 10
139
+ }), o = this.view.toScreen(t), l = await this.createCountdownCanvas(), h = l[0], r = l[1];
140
+ h.style.left = o.x + "px", h.style.top = o.y + "px", r.style.left = o.x + "px", r.style.top = o.y + "px", this.countdownCanvasMap.set(e, {
142
141
  backgroundCanvas: h,
143
142
  countdownCanvas: r,
144
- mapPoint: s
145
- }), this.drawCountdownText(r, o);
146
- });
147
- }
148
- this.countdownWatchHandel || (this.countdownWatchHandel = c.watch(
143
+ mapPoint: t
144
+ }), this.drawCountdownText(r, n);
145
+ } catch (t) {
146
+ console.log("倒计时canvas创建失败", e, t);
147
+ }
148
+ this.countdownWatchHandel || (this.countdownWatchHandel = d.watch(
149
149
  () => this.view.extent,
150
150
  () => {
151
- this.countdownCanvasMap.forEach((s) => {
152
- const n = this.view.toScreen(s.mapPoint);
153
- s.backgroundCanvas.style.left = n.x + "px", s.backgroundCanvas.style.top = n.y + "px", s.countdownCanvas.style.left = n.x + "px", s.countdownCanvas.style.top = n.y + "px";
151
+ this.countdownCanvasMap.forEach((t) => {
152
+ const o = this.view.toScreen(t.mapPoint);
153
+ t.backgroundCanvas.style.left = o.x + "px", t.backgroundCanvas.style.top = o.y + "px", t.countdownCanvas.style.left = o.x + "px", t.countdownCanvas.style.top = o.y + "px";
154
154
  });
155
155
  }
156
156
  ));
157
157
  }
158
158
  /**
159
159
  * 在倒计时面板上写入倒计时时间
160
- * @param countdownCanvas 倒计时面板canvas
160
+ * @param canvas 倒计时面板canvas
161
161
  * @param rtStage 相位数据
162
162
  * @param rtStage.stageID 相位名
163
163
  * @param rtStage.stageRemainingTime 剩余时间
164
164
  * @param rtStage.stageAllRedTime 全红时间
165
165
  * @param rtStage.stageYellowTime 黄灯时间
166
166
  */
167
- drawCountdownText(a, e) {
168
- const i = a.getContext("2d");
169
- i.clearRect(0, 0, a.width, a.height), i.font = "32px Digital", i.textBaseline = "middle", i.textAlign = "center", i.fillStyle = e.stageRemainingTime <= e.stageAllRedTime ? "red" : e.stageRemainingTime <= e.stageAllRedTime + e.stageYellowTime ? "yellow" : "lime", i.fillText(
170
- `${e.stageID} ${e.stageRemainingTime.toFixed(0)}`,
171
- a.width / 2,
172
- a.height / 2
167
+ drawCountdownText(e, a) {
168
+ const i = e.getContext("2d");
169
+ i.clearRect(0, 0, e.width, e.height), i.font = "24px Digital", i.textBaseline = "middle", i.textAlign = "center", i.fillStyle = a.stageRemainingTime <= a.stageAllRedTime ? "red" : a.stageRemainingTime <= a.stageAllRedTime + a.stageYellowTime ? "yellow" : "lime", i.fillText(
170
+ `${a.stageID} ${a.stageRemainingTime.toFixed(0)}`,
171
+ e.width / 2,
172
+ e.height / 2
173
+ );
174
+ }
175
+ drawCircle(e, a) {
176
+ console.log(a);
177
+ const i = e.getContext("2d");
178
+ i.clearRect(0, 0, e.width, e.height), this.ctxDraw(
179
+ i,
180
+ "lime",
181
+ e.width / 2,
182
+ e.height / 2,
183
+ 20,
184
+ -Math.PI / 2,
185
+ -Math.PI / 2 + 2 * 0.6 * Math.PI
173
186
  );
174
187
  }
175
- async updatePhaseLine(a, e, i) {
176
- const o = this.phaseLineLayer.source.filter(
177
- (t) => t.getAttribute("id").includes(a)
188
+ ctxDraw(e, a, i, n, s, t, o) {
189
+ e.save, e.beginPath(), e.lineWidth = 4, e.strokeStyle = a, e.arc(i, n, s, t, o), e.stroke(), e.closePath(), e.font = "26px Digital", e.textBaseline = "middle", e.textAlign = "center", e.fillText("A", i, n), e.restore();
190
+ }
191
+ async updatePhaseLine(e, a, i) {
192
+ const n = this.phaseLineLayer.source.filter(
193
+ (s) => s.getAttribute("id").includes(e)
178
194
  );
179
- o.forEach((t) => {
180
- const s = t.getAttribute("id");
181
- this.isLaneInChannels(s, e) ? t.setAttribute("color", "green") : this.isLaneInChannels(s, i) ? t.setAttribute("color", "red") : t.setAttribute("color", "green");
182
- }), await this.phaseLineLayer.applyEdits({ updateFeatures: o });
195
+ n.forEach((s) => {
196
+ const t = s.getAttribute("id");
197
+ this.isLaneInChannels(t, a) ? s.setAttribute("color", "green") : this.isLaneInChannels(t, i) ? s.setAttribute("color", "red") : s.setAttribute("color", "green");
198
+ }), await this.phaseLineLayer.applyEdits({ updateFeatures: n });
183
199
  }
184
200
  /**
185
201
  * 车道是否在通道中
@@ -187,26 +203,30 @@ class f {
187
203
  * @param channels 通道列表
188
204
  * @returns
189
205
  */
190
- isLaneInChannels(a, e) {
191
- const i = a.split("+"), o = i[1], t = i[2];
192
- for (let s = 0; s < e.length; s++)
193
- for (let n = 0; n < e[s].laneSnList.length; n++) {
194
- const l = e[s].laneSnList[n].toFixed(0);
195
- if (o === l[0] && t === l[1])
206
+ isLaneInChannels(e, a) {
207
+ const i = e.split("+"), n = i[1], s = i[2];
208
+ for (let t = 0; t < a.length; t++)
209
+ for (let o = 0; o < a[t].laneSnList.length; o++) {
210
+ const l = a[t].laneSnList[o].toFixed(0);
211
+ if (n === l[0] && s === l[1])
196
212
  return !0;
197
213
  }
198
214
  return !1;
199
215
  }
200
- createCountdownCanvas(a) {
201
- const e = new Image();
202
- e.src = `${this.mapConfig.assetsRoot}/Images/timeboard/CountdownBG.png`, e.onload = () => {
203
- const i = document.createElement("canvas");
204
- i.width = this.canvasWidth, i.height = this.canvasHeight, i.style.position = "absolute", i.style.transform = "translate(-50%, -50%)", i.getContext("2d").drawImage(e, 0, 0, this.canvasWidth, this.canvasHeight), this.view.container.appendChild(i);
205
- const t = document.createElement("canvas");
206
- t.width = this.canvasWidth - 10, t.height = this.canvasHeight - 10, t.style.position = "absolute", t.style.transform = "translate(-50%, -50%)", this.view.container.appendChild(t), a([i, t]);
207
- }, e.onerror = () => {
208
- console.error("倒计时背景图加载失败");
209
- };
216
+ createCountdownCanvas() {
217
+ return new Promise((e, a) => {
218
+ const i = new Image();
219
+ i.src = `${this.mapConfig.assetsRoot}/Images/timeboard/CountdownBG1.png`, i.onload = () => {
220
+ const n = document.createElement("canvas");
221
+ n.width = this.canvasWidth, n.height = this.canvasHeight, n.style.position = "absolute", n.style.transform = "translate(-50%, -50%)", n.getContext(
222
+ "2d"
223
+ ).drawImage(i, 0, 0, this.canvasWidth, this.canvasHeight), this.view.container.appendChild(n);
224
+ const t = document.createElement("canvas");
225
+ t.width = this.canvasWidth - 10, t.height = this.canvasHeight - 10, t.style.position = "absolute", t.style.transform = "translate(-50%, -50%)", this.view.container.appendChild(t), e([n, t]);
226
+ }, i.onerror = (n) => {
227
+ a(n);
228
+ };
229
+ });
210
230
  }
211
231
  }
212
232
  export {
@@ -27,7 +27,7 @@ export default class SignalHoloFlow {
27
27
  private updateCountdown;
28
28
  /**
29
29
  * 在倒计时面板上写入倒计时时间
30
- * @param countdownCanvas 倒计时面板canvas
30
+ * @param canvas 倒计时面板canvas
31
31
  * @param rtStage 相位数据
32
32
  * @param rtStage.stageID 相位名
33
33
  * @param rtStage.stageRemainingTime 剩余时间
@@ -35,6 +35,8 @@ export default class SignalHoloFlow {
35
35
  * @param rtStage.stageYellowTime 黄灯时间
36
36
  */
37
37
  private drawCountdownText;
38
+ private drawCircle;
39
+ private ctxDraw;
38
40
  private updatePhaseLine;
39
41
  /**
40
42
  * 车道是否在通道中
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("@arcgis/core/core/reactiveUtils"),p=require("@arcgis/core/geometry"),u=require("@arcgis/core/layers/FeatureLayer"),y=require("../../stores/index.js");function g(l){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const e in l)if(e!=="default"){const a=Object.getOwnPropertyDescriptor(l,e);Object.defineProperty(t,e,a.get?a:{enumerable:!0,get:()=>l[e]})}}return t.default=l,Object.freeze(t)}const m=g(d);class f{constructor(t){this.currentPhaseMap=new Map,this.countdownCanvasMap=new Map,this.lastDataTime=0,this.isDeletingCanvas=!1,this.canvasWidth=120,this.canvasHeight=50,this.view=(t.type==="2d",t);const e=y.default.useAppDataStore;this.mapConfig=JSON.parse(JSON.stringify(e.mapConfig))}async initializeLayer(){if(this.mapConfig.phaseLineLayer)if(this.phaseLineLayer)this.phaseLineLayer.visible||(this.phaseLineLayer.visible=!0);else{const t=`${this.mapConfig.assetsRoot}/${this.mapConfig.phaseLineLayer}`,o=(await(await fetch(t)).json()).features.map((n,i)=>({geometry:{type:"polyline",paths:[n.geometry.coordinates]},attributes:{ObjectID:i+1,id:n.properties.id,color:"hide"}}));this.phaseLineLayer=new u({source:o,geometryType:"polyline",objectIdField:"ObjectID",outFields:["*"],fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"color",alias:"color",type:"string"}],renderer:{type:"unique-value",field:"color",defaultSymbol:{type:"simple-line",color:"lightblue",width:"2px",style:"none"},uniqueValueInfos:[{value:"green",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[19,255,69,.8]},width:1,height:.5}]}},{value:"red",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[254,5,9,.8]},width:1,height:.5}]}},{value:"yellow",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[255,215,0,.8]},width:1,height:.5}]}}]}}),this.view.map.add(this.phaseLineLayer)}}async handleSignalData(t){const{crossId:e,lat:a,lon:o,rtStage:n,channelsConfig:i}=t;await this.updateCountdown(e,a,o,n),!(!this.phaseLineLayer||!i)&&((!this.currentPhaseMap.has(e)||this.currentPhaseMap.get(e)!==n.stagePhase)&&await this.updatePhaseLine(e,n.channelsConfig,i),this.currentPhaseMap.set(e,n.stagePhase))}clearSignal(){this.phaseLineLayer&&(this.phaseLineLayer.visible=!1),this.countdownWatchHandel&&(this.countdownWatchHandel.remove(),this.countdownWatchHandel=void 0),this.countdownCanvasMap.forEach(t=>{this.view.container.removeChild(t.backgroundCanvas),this.view.container.removeChild(t.countdownCanvas)}),this.countdownCanvasMap.clear()}async updateCountdown(t,e,a,o){if(this.isDeletingCanvas)return;const n=this.countdownCanvasMap.get(t);if(n)this.drawCountdownText(n.countdownCanvas,o);else{const i=new p.Point({longitude:a,latitude:e,z:10}),s=this.view.toScreen(i);this.createCountdownCanvas(r=>{const c=r[0],h=r[1];c.style.left=s.x+"px",c.style.top=s.y+"px",h.style.left=s.x+"px",h.style.top=s.y+"px",this.countdownCanvasMap.set(t,{backgroundCanvas:c,countdownCanvas:h,mapPoint:i}),this.drawCountdownText(h,o)})}this.countdownWatchHandel||(this.countdownWatchHandel=m.watch(()=>this.view.extent,()=>{this.countdownCanvasMap.forEach(i=>{const s=this.view.toScreen(i.mapPoint);i.backgroundCanvas.style.left=s.x+"px",i.backgroundCanvas.style.top=s.y+"px",i.countdownCanvas.style.left=s.x+"px",i.countdownCanvas.style.top=s.y+"px"})}))}drawCountdownText(t,e){const a=t.getContext("2d");a.clearRect(0,0,t.width,t.height),a.font="32px Digital",a.textBaseline="middle",a.textAlign="center",a.fillStyle=e.stageRemainingTime<=e.stageAllRedTime?"red":e.stageRemainingTime<=e.stageAllRedTime+e.stageYellowTime?"yellow":"lime",a.fillText(`${e.stageID} ${e.stageRemainingTime.toFixed(0)}`,t.width/2,t.height/2)}async updatePhaseLine(t,e,a){const o=this.phaseLineLayer.source.filter(n=>n.getAttribute("id").includes(t));o.forEach(n=>{const i=n.getAttribute("id");this.isLaneInChannels(i,e)?n.setAttribute("color","green"):this.isLaneInChannels(i,a)?n.setAttribute("color","red"):n.setAttribute("color","green")}),await this.phaseLineLayer.applyEdits({updateFeatures:o})}isLaneInChannels(t,e){const a=t.split("+"),o=a[1],n=a[2];for(let i=0;i<e.length;i++)for(let s=0;s<e[i].laneSnList.length;s++){const r=e[i].laneSnList[s].toFixed(0);if(o===r[0]&&n===r[1])return!0}return!1}createCountdownCanvas(t){const e=new Image;e.src=`${this.mapConfig.assetsRoot}/Images/timeboard/CountdownBG.png`,e.onload=()=>{const a=document.createElement("canvas");a.width=this.canvasWidth,a.height=this.canvasHeight,a.style.position="absolute",a.style.transform="translate(-50%, -50%)",a.getContext("2d").drawImage(e,0,0,this.canvasWidth,this.canvasHeight),this.view.container.appendChild(a);const n=document.createElement("canvas");n.width=this.canvasWidth-10,n.height=this.canvasHeight-10,n.style.position="absolute",n.style.transform="translate(-50%, -50%)",this.view.container.appendChild(n),t([a,n])},e.onerror=()=>{console.error("倒计时背景图加载失败")}}}exports.default=f;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("@arcgis/core/core/reactiveUtils"),u=require("@arcgis/core/geometry"),p=require("@arcgis/core/layers/FeatureLayer"),g=require("../../stores/index.js");function y(l){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const t in l)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(l,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>l[t]})}}return e.default=l,Object.freeze(e)}const w=y(d);class m{constructor(e){this.currentPhaseMap=new Map,this.countdownCanvasMap=new Map,this.lastDataTime=0,this.isDeletingCanvas=!1,this.canvasWidth=80,this.canvasHeight=40,this.view=(e.type==="2d",e);const t=g.default.useAppDataStore;this.mapConfig=JSON.parse(JSON.stringify(t.mapConfig))}async initializeLayer(){if(this.mapConfig.phaseLineLayer)if(this.phaseLineLayer)this.phaseLineLayer.visible||(this.phaseLineLayer.visible=!0);else{const e=`${this.mapConfig.assetsRoot}/${this.mapConfig.phaseLineLayer}`,i=(await(await fetch(e)).json()).features.map((s,a)=>({geometry:{type:"polyline",paths:[s.geometry.coordinates]},attributes:{ObjectID:a+1,id:s.properties.id,color:"hide"}}));this.phaseLineLayer=new p({source:i,geometryType:"polyline",objectIdField:"ObjectID",outFields:["*"],fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"color",alias:"color",type:"string"}],renderer:{type:"unique-value",field:"color",defaultSymbol:{type:"simple-line",color:"lightblue",width:"2px",style:"none"},uniqueValueInfos:[{value:"green",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[19,255,69,.8]},width:1,height:.5}]}},{value:"red",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[254,5,9,.8]},width:1,height:.5}]}},{value:"yellow",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[255,215,0,.8]},width:1,height:.5}]}}]}}),this.view.map.add(this.phaseLineLayer)}}async handleSignalData(e){const{crossId:t,lat:n,lon:i,rtStage:s,channelsConfig:a}=e;await this.updateCountdown(t,n,i,s),!(!this.phaseLineLayer||!a)&&((!this.currentPhaseMap.has(t)||this.currentPhaseMap.get(t)!==s.stagePhase)&&await this.updatePhaseLine(t,s.channelsConfig,a),this.currentPhaseMap.set(t,s.stagePhase))}clearSignal(){this.phaseLineLayer&&(this.phaseLineLayer.visible=!1),this.countdownWatchHandel&&(this.countdownWatchHandel.remove(),this.countdownWatchHandel=void 0),this.countdownCanvasMap.forEach(e=>{this.view.container.removeChild(e.backgroundCanvas),this.view.container.removeChild(e.countdownCanvas)}),this.countdownCanvasMap.clear()}async updateCountdown(e,t,n,i){if(this.isDeletingCanvas)return;const s=this.countdownCanvasMap.get(e);if(s)this.drawCountdownText(s.countdownCanvas,i);else try{const a=new u.Point({longitude:n,latitude:t,z:10}),o=this.view.toScreen(a),r=await this.createCountdownCanvas(),c=r[0],h=r[1];c.style.left=o.x+"px",c.style.top=o.y+"px",h.style.left=o.x+"px",h.style.top=o.y+"px",this.countdownCanvasMap.set(e,{backgroundCanvas:c,countdownCanvas:h,mapPoint:a}),this.drawCountdownText(h,i)}catch(a){console.log("倒计时canvas创建失败",e,a)}this.countdownWatchHandel||(this.countdownWatchHandel=w.watch(()=>this.view.extent,()=>{this.countdownCanvasMap.forEach(a=>{const o=this.view.toScreen(a.mapPoint);a.backgroundCanvas.style.left=o.x+"px",a.backgroundCanvas.style.top=o.y+"px",a.countdownCanvas.style.left=o.x+"px",a.countdownCanvas.style.top=o.y+"px"})}))}drawCountdownText(e,t){const n=e.getContext("2d");n.clearRect(0,0,e.width,e.height),n.font="24px Digital",n.textBaseline="middle",n.textAlign="center",n.fillStyle=t.stageRemainingTime<=t.stageAllRedTime?"red":t.stageRemainingTime<=t.stageAllRedTime+t.stageYellowTime?"yellow":"lime",n.fillText(`${t.stageID} ${t.stageRemainingTime.toFixed(0)}`,e.width/2,e.height/2)}drawCircle(e,t){console.log(t);const n=e.getContext("2d");n.clearRect(0,0,e.width,e.height),this.ctxDraw(n,"lime",e.width/2,e.height/2,20,-Math.PI/2,-Math.PI/2+2*.6*Math.PI)}ctxDraw(e,t,n,i,s,a,o){e.save,e.beginPath(),e.lineWidth=4,e.strokeStyle=t,e.arc(n,i,s,a,o),e.stroke(),e.closePath(),e.font="26px Digital",e.textBaseline="middle",e.textAlign="center",e.fillText("A",n,i),e.restore()}async updatePhaseLine(e,t,n){const i=this.phaseLineLayer.source.filter(s=>s.getAttribute("id").includes(e));i.forEach(s=>{const a=s.getAttribute("id");this.isLaneInChannels(a,t)?s.setAttribute("color","green"):this.isLaneInChannels(a,n)?s.setAttribute("color","red"):s.setAttribute("color","green")}),await this.phaseLineLayer.applyEdits({updateFeatures:i})}isLaneInChannels(e,t){const n=e.split("+"),i=n[1],s=n[2];for(let a=0;a<t.length;a++)for(let o=0;o<t[a].laneSnList.length;o++){const r=t[a].laneSnList[o].toFixed(0);if(i===r[0]&&s===r[1])return!0}return!1}createCountdownCanvas(){return new Promise((e,t)=>{const n=new Image;n.src=`${this.mapConfig.assetsRoot}/Images/timeboard/CountdownBG1.png`,n.onload=()=>{const i=document.createElement("canvas");i.width=this.canvasWidth,i.height=this.canvasHeight,i.style.position="absolute",i.style.transform="translate(-50%, -50%)",i.getContext("2d").drawImage(n,0,0,this.canvasWidth,this.canvasHeight),this.view.container.appendChild(i);const a=document.createElement("canvas");a.width=this.canvasWidth-10,a.height=this.canvasHeight-10,a.style.position="absolute",a.style.transform="translate(-50%, -50%)",this.view.container.appendChild(a),e([i,a])},n.onerror=i=>{t(i)}})}}exports.default=m;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gisviewer-vue3-arcgis",
3
- "version": "1.0.95",
3
+ "version": "1.0.96",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [