-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex_GCWA_Canal_Flow_Map_na.html
1030 lines (845 loc) · 33.7 KB
/
index_GCWA_Canal_Flow_Map_na.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<title>Gulf Coast Water Authority Office</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix.js"></script>
<link rel="stylesheet" href="https://js.arcgis.com/4.22/esri/themes/light/main.css" />
<script src="https://js.arcgis.com/4.22/"></script>
<script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Open+Sans:400,700&display=swap'>
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css'><link rel="stylesheet" href="./style.css">
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.0.1/tailwind.min.css'>
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.0.1/tailwind.min.css'>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./na_files/style.css">
<!-- Boxicons CSS -->
<link href='https://unpkg.com/[email protected]/css/boxicons.min.css' rel='stylesheet'>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- jQuery code to show
the working of this method -->
<script>
$(document).ready(function() {
$("button").click(function() {
$("html, body").animate({
scrollTop: $(
'html, body').get(0).scrollHeight
}, 2000);
});
});
</script>
<script>
$(document).ready(function() {
$('a[href=#top]').click(function(){
$('html, body').animate({scrollTop:0}, 'slow');
return false;
});
});
</script>
<style>
.rotate-45 {
--transform-rotate: 45deg;
transform: rotate(45deg);
}
.group:hover .group-hover\:flex {
display: flex;
}
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
#paneDiv {
position: absolute;
bottom: 40px;
width: 100%;
text-align: center;
background-color: transparent;
color: rgb(43, 68, 78);
}
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
font-family: verdana;
}
.esri-button-overwrite {
width:auto;
display: table-cell;
margin: 4px;
background-color: rgb(255, 255, 255);
color: #0079c1;
}
#info {
z-index: 9975;
position: absolute;
top: 10px;
left: 0;
right: 0;
text-align: center;
padding: 05px 10px 5px 10px;
margin-left: auto;
margin-right: auto;
width: 50%;
background: rgba(255, 255, 255, 0.7);
font-size: 20pt;
}
.esri-editor .esri-item-list__scroller {
max-height: 150px;
}
#topbar {
background: rgb(18, 34, 179);
position: absolute;
top: 15px;
right: 15px;
padding: 10px;
}
.action-button {
font-size: 16px;
background-color: transparent;
border: 1px solid #4812c5;
color: #6e6e6e;
height: 32px;
width: 32px;
text-align: center;
box-shadow: 0 0 1px rgba(0, 0, 0, 0.3);
}
.action-button:hover,
.action-button:focus {
background: #0079c1;
color: #171bdf;
}
.active {
background: #0079c1;
color: #121fd4;
}
</style>
<script>
require([
"esri/Map",
"esri/request",
"esri/core/watchUtils",
"esri/geometry/support/webMercatorUtils",
"esri/layers/GraphicsLayer",
"esri/views/MapView",
"esri/views/2d/layers/BaseLayerViewGL2D"
], (
Map,
esriRequest,
watchUtils,
webMercatorUtils,
GraphicsLayer,
MapView,
BaseLayerViewGL2D
) => {
// Subclass the custom layer view from BaseLayerViewGL2D.
const CustomLayerView2D = BaseLayerViewGL2D.createSubclass({
// Locations of the two vertex attributes that we use. They
// will be bound to the shader program before linking.
aPosition: 0,
aOffset: 1,
aDistance: 2,
aSide: 3,
aColor: 4,
constructor: function() {
// Geometrical transformations that must be recomputed
// from scratch at every frame.
this.transform = mat3.create();
this.extrude = mat3.create();
this.translationToCenter = vec2.create();
this.screenTranslation = vec2.create();
// Geometrical transformations whose only a few elements
// must be updated per frame. Those elements are marked
// with NaN.
this.display = mat3.fromValues(NaN, 0, 0, 0, NaN, 0, -1, 1, 1);
this.screenScaling = vec3.fromValues(NaN, NaN, 1);
// Whether the vertex and index buffers need to be updated
// due to a change in the layer data.
this.needsUpdate = false;
// We listen for changes to the graphics collection of the layer
// and trigger the generation of new frames. A frame rendered while
// `needsUpdate` is true may cause an update of the vertex and
// index buffers.
const requestUpdate = () => {
this.needsUpdate = true;
this.requestRender();
};
this.watcher = watchUtils.on(
this,
"layer.graphics",
"change",
requestUpdate,
requestUpdate,
requestUpdate
);
},
// Called once a custom layer is added to the map.layers collection and this layer view is instantiated.
attach: function() {
const gl = this.context;
const vertexSource = `
precision highp float;
uniform mat3 u_transform;
uniform mat3 u_extrude;
uniform mat3 u_display;
attribute vec2 a_position;
attribute vec2 a_offset;
attribute float a_distance;
attribute float a_side;
attribute vec4 a_color;
varying float v_distance;
varying float v_side;
varying vec4 v_color;
void main(void) {
gl_Position.xy = (u_display * (u_transform * vec3(a_position, 1.0) + u_extrude * vec3(a_offset, 0.0))).xy;
gl_Position.zw = vec2(0.0, 1.0);
v_distance = a_distance;
v_side = a_side;
v_color = a_color;
}`;
const fragmentSource = `
precision highp float;
uniform float u_current_time;
varying float v_distance;
varying float v_side;
varying vec4 v_color;
const float TRAIL_SPEED = 200.0;
const float TRAIL_LENGTH = 3000.0;
const float TRAIL_CYCLE = 2000.0;
void main(void) {
float d = mod(v_distance - u_current_time * TRAIL_SPEED, TRAIL_CYCLE);
float a1 = d < TRAIL_LENGTH ? mix(0.0, 1.0, d / TRAIL_LENGTH) : 0.0;
float a2 = exp(-abs(v_side) * 3.0);
float a = a1 * a2;
gl_FragColor = v_color * a;
}`;
const vertexShader = gl.createShader(gl.VERTEX_SHADER);
gl.shaderSource(vertexShader, vertexSource);
gl.compileShader(vertexShader);
const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
gl.shaderSource(fragmentShader, fragmentSource);
gl.compileShader(fragmentShader);
// Create the shader program.
this.program = gl.createProgram();
gl.attachShader(this.program, vertexShader);
gl.attachShader(this.program, fragmentShader);
// Bind attributes.
gl.bindAttribLocation(this.program, this.aPosition, "a_position");
gl.bindAttribLocation(this.program, this.aOffset, "a_offset");
gl.bindAttribLocation(this.program, this.aDistance, "a_distance");
gl.bindAttribLocation(this.program, this.aSide, "a_side");
gl.bindAttribLocation(this.program, this.aColor, "a_color");
// Link.
gl.linkProgram(this.program);
// Shader objects are not needed anymore.
gl.deleteShader(vertexShader);
gl.deleteShader(fragmentShader);
// Retrieve uniform locations once and for all.
this.uTransform = gl.getUniformLocation(
this.program,
"u_transform"
);
this.uExtrude = gl.getUniformLocation(
this.program,
"u_extrude"
);
this.uDisplay = gl.getUniformLocation(this.program, "u_display");
this.uCurrentTime = gl.getUniformLocation(
this.program,
"u_current_time"
);
// Create the vertex and index buffer. They are initially empty. We need to track the
// size of the index buffer because we use indexed drawing.
this.vertexBuffer = gl.createBuffer();
this.indexBuffer = gl.createBuffer();
// Number of indices in the index buffer.
this.indexBufferSize = 0;
// When certain conditions occur, we update the buffers and re-compute and re-encode
// all the attributes. When buffer update occurs, we also take note of the current center
// of the view state, and we reset a vector called `translationToCenter` to [0, 0], meaning that the
// current center is the same as it was when the attributes were recomputed.
this.centerAtLastUpdate = vec2.fromValues(
this.view.state.center[0],
this.view.state.center[1]
);
},
// Called once a custom layer is removed from the map.layers collection and this layer view is destroyed.
detach: function() {
// Stop watching the `layer.graphics` collection.
this.watcher.remove();
const gl = this.context;
// Delete buffers and programs.
gl.deleteBuffer(this.vertexBuffer);
gl.deleteBuffer(this.indexBuffer);
gl.deleteProgram(this.program);
},
// Called every time a frame is rendered.
render: function(renderParameters) {
const gl = renderParameters.context;
const state = renderParameters.state;
// Update vertex positions. This may trigger an update of
// the vertex coordinates contained in the vertex buffer.
// There are three kinds of updates:
this.updatePositions(renderParameters);
// If there is nothing to render we return.
if (this.indexBufferSize === 0) {
return;
}
// Update view `transform` matrix; it converts from map units to pixels.
mat3.identity(this.transform);
this.screenTranslation[0] = (state.pixelRatio * state.size[0]) / 2;
this.screenTranslation[1] = (state.pixelRatio * state.size[1]) / 2;
mat3.translate(
this.transform,
this.transform,
this.screenTranslation
);
mat3.rotate(
this.transform,
this.transform,
(Math.PI * state.rotation) / 180
);
this.screenScaling[0] = state.pixelRatio / state.resolution;
this.screenScaling[1] = -state.pixelRatio / state.resolution;
mat3.scale(this.transform, this.transform, this.screenScaling);
mat3.translate(
this.transform,
this.transform,
this.translationToCenter
);
// Update view `extrude` matrix; it causes offset vectors to rotate and scale
// with the view, but caps the maximum width a polyline is allowed to be.
mat3.identity(this.extrude);
mat3.rotate(
this.extrude,
this.extrude,
(Math.PI * state.rotation) / 180
);
const HALF_WIDTH = 6;
mat3.scale(this.extrude, this.extrude, [HALF_WIDTH, -HALF_WIDTH, 1]);
// Update view `display` matrix; it converts from pixels to normalized device coordinates.
this.display[0] = 2 / (state.pixelRatio * state.size[0]);
this.display[4] = -2 / (state.pixelRatio * state.size[1]);
// Draw.
gl.useProgram(this.program);
gl.uniformMatrix3fv(this.uTransform, false, this.transform);
gl.uniformMatrix3fv(this.uExtrude, false, this.extrude);
gl.uniformMatrix3fv(this.uDisplay, false, this.display);
gl.uniform1f(this.uCurrentTime, performance.now() / 1000.0);
gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer);
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
gl.enableVertexAttribArray(this.aPosition);
gl.enableVertexAttribArray(this.aOffset);
gl.enableVertexAttribArray(this.aDistance);
gl.enableVertexAttribArray(this.aSide);
gl.enableVertexAttribArray(this.aColor);
gl.vertexAttribPointer(this.aPosition, 2, gl.FLOAT, false, 28, 0);
gl.vertexAttribPointer(this.aOffset, 2, gl.FLOAT, false, 28, 8);
gl.vertexAttribPointer(this.aDistance, 1, gl.FLOAT, false, 28, 16);
gl.vertexAttribPointer(this.aSide, 1, gl.FLOAT, false, 28, 20);
gl.vertexAttribPointer(this.aColor, 4, gl.UNSIGNED_BYTE, true, 28, 24);
gl.enable(gl.BLEND);
gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
gl.drawElements(
gl.TRIANGLES,
this.indexBufferSize,
gl.UNSIGNED_SHORT,
0
);
// Request new render because markers are animated.
this.requestRender();
},
// Called internally from render().
updatePositions: function(renderParameters) {
const gl = renderParameters.context;
const stationary = renderParameters.stationary;
const state = renderParameters.state;
// If we are not stationary we simply update the `translationToCenter` vector.
if (!stationary) {
vec2.sub(
this.translationToCenter,
this.centerAtLastUpdate,
state.center
);
this.requestRender();
return;
}
// If we are stationary, the `layer.graphics` collection has not changed, and
// we are centered on the `centerAtLastUpdate`, we do nothing.
if (
!this.needsUpdate &&
this.translationToCenter[0] === 0 &&
this.translationToCenter[1] === 0
) {
return;
}
// Otherwise, we record the new encoded center, which imply a reset of the `translationToCenter` vector,
// we record the update time, and we proceed to update the buffers.
this.centerAtLastUpdate.set(state.center);
this.translationToCenter[0] = 0;
this.translationToCenter[1] = 0;
this.needsUpdate = false;
const graphics = this.layer.graphics;
// Allocate memory.
let vtxCount = 0;
let idxCount = 0;
for (let i = 0; i < graphics.items.length; ++i) {
const graphic = graphics.items[i];
const path = graphic.geometry.paths[0];
vtxCount += path.length * 2;
idxCount += (path.length - 1) * 6;
}
const vertexData = new ArrayBuffer(7 * vtxCount * 4);
const floatData = new Float32Array(vertexData);
const colorData = new Uint8Array(vertexData);
const indexData = new Uint16Array(idxCount);
let vtxCursor = 0;
let idxCursor = 0;
for (let i = 0; i < graphics.items.length; ++i) {
const graphic = graphics.items[i];
const path = graphic.geometry.paths[0];
const color = graphic.attributes["color"];
// Initialize new triangulation state.
let s = {};
// Process each vertex.
for (let j = 0; j < path.length; ++j) {
// Point p is an original vertex of the polyline; we need to produce two extruded
// GPU vertices, for each original vertex.
const p = path[j];
if (s.current) {
// If this is not the first point, we compute the vector between the previous
// and the next vertex.
s.delta = [p[0] - s.current[0], p[1] - s.current[1]];
// And we normalize it. This is the direction of the current line segment
// that we are processing.
const deltaLength = Math.sqrt(s.delta[0] * s.delta[0] + s.delta[1] * s.delta[1]);
s.direction = [s.delta[0] / deltaLength, s.delta[1] / deltaLength];
// We want to compute the normal to that segment. The normal of a
// vector (x, y) can be computed by rotating it by 90 degrees; this yields (-y, x).
const normal = [-s.direction[1], s.direction[0]];
if (s.normal) {
// If there is already a normal vector in the state, then the offset is the
// average of that normal and the next normal, i.e. the bisector of the turn.
s.offset = [s.normal[0] + normal[0], s.normal[1] + normal[1]];
// We first normalize it.
const offsetLength = Math.sqrt(s.offset[0] * s.offset[0] + s.offset[1] * s.offset[1]);
s.offset[0] /= offsetLength;
s.offset[1] /= offsetLength;
// Then we scale it like the cosine of the half turn angle. This can
// be computed as the dot product between the previous normal and the
// normalized bisector.
const d = s.normal[0] * s.offset[0] + s.normal[1] * s.offset[1];
s.offset[0] /= d;
s.offset[1] /= d;
} else {
// Otherwise, this is the offset of the first vertex; it is equal to the
// normal we just computed.
s.offset = [normal[0], normal[1]];
}
// All the values that we computed are written to the first GPU vertex.
floatData[vtxCursor * 7 + 0] = s.current[0] - this.centerAtLastUpdate[0];
floatData[vtxCursor * 7 + 1] = s.current[1] - this.centerAtLastUpdate[1];
floatData[vtxCursor * 7 + 2] = s.offset[0];
floatData[vtxCursor * 7 + 3] = s.offset[1];
floatData[vtxCursor * 7 + 4] = s.distance;
floatData[vtxCursor * 7 + 5] = +1;
colorData[4 * (vtxCursor * 7 + 6) + 0] = color[0];
colorData[4 * (vtxCursor * 7 + 6) + 1] = color[1];
colorData[4 * (vtxCursor * 7 + 6) + 2] = color[2];
colorData[4 * (vtxCursor * 7 + 6) + 3] = 255;
// We also write the same values to the second vertex, but we negate the
// offset and the side (these are the attributes at positions +9, +10 and +12).
floatData[vtxCursor * 7 + 7] = s.current[0] - this.centerAtLastUpdate[0];
floatData[vtxCursor * 7 + 8] = s.current[1] - this.centerAtLastUpdate[1];
floatData[vtxCursor * 7 + 9] = -s.offset[0];
floatData[vtxCursor * 7 + 10] = -s.offset[1];
floatData[vtxCursor * 7 + 11] = s.distance;
floatData[vtxCursor * 7 + 12] = -1;
colorData[4 * (vtxCursor * 7 + 13) + 0] = color[0];
colorData[4 * (vtxCursor * 7 + 13) + 1] = color[1];
colorData[4 * (vtxCursor * 7 + 13) + 2] = color[2];
colorData[4 * (vtxCursor * 7 + 13) + 3] = 255;
vtxCursor += 2;
if (j >= 2) {
// If this is the third iteration then it means that we have emitted
// four GPU vertices already; we can form a triangle with them.
indexData[idxCursor + 0] = vtxCursor - 4;
indexData[idxCursor + 1] = vtxCursor - 3;
indexData[idxCursor + 2] = vtxCursor - 2;
indexData[idxCursor + 3] = vtxCursor - 3;
indexData[idxCursor + 4] = vtxCursor - 1;
indexData[idxCursor + 5] = vtxCursor - 2;
idxCursor += 6;
}
// The next normal becomes the current normal at the next iteration.
s.normal = normal;
// We increment the distance along the line by the length of the segment
// that we just processed.
s.distance += deltaLength;
} else {
s.distance = 0;
}
// We move to the next point.
s.current = p;
}
// Finishing up (last 2 extruded vertices and 6 indices).
s.offset = [s.normal[0], s.normal[1]];
floatData[vtxCursor * 7 + 0] = s.current[0] - this.centerAtLastUpdate[0];
floatData[vtxCursor * 7 + 1] = s.current[1] - this.centerAtLastUpdate[1];
floatData[vtxCursor * 7 + 2] = s.offset[0];
floatData[vtxCursor * 7 + 3] = s.offset[1];
floatData[vtxCursor * 7 + 4] = s.distance;
floatData[vtxCursor * 7 + 5] = +1;
colorData[4 * (vtxCursor * 7 + 6) + 0] = color[0];
colorData[4 * (vtxCursor * 7 + 6) + 1] = color[1];
colorData[4 * (vtxCursor * 7 + 6) + 2] = color[2];
colorData[4 * (vtxCursor * 7 + 6) + 3] = 255;
floatData[vtxCursor * 7 + 7] = s.current[0] - this.centerAtLastUpdate[0];
floatData[vtxCursor * 7 + 8] = s.current[1] - this.centerAtLastUpdate[1];
floatData[vtxCursor * 7 + 9] = -s.offset[0];
floatData[vtxCursor * 7 + 10] = -s.offset[1];
floatData[vtxCursor * 7 + 11] = s.distance;
floatData[vtxCursor * 7 + 12] = -1;
colorData[4 * (vtxCursor * 7 + 13) + 0] = color[0];
colorData[4 * (vtxCursor * 7 + 13) + 1] = color[1];
colorData[4 * (vtxCursor * 7 + 13) + 2] = color[2];
colorData[4 * (vtxCursor * 7 + 13) + 3] = 255;
vtxCursor += 2;
indexData[idxCursor + 0] = vtxCursor - 4;
indexData[idxCursor + 1] = vtxCursor - 3;
indexData[idxCursor + 2] = vtxCursor - 2;
indexData[idxCursor + 3] = vtxCursor - 3;
indexData[idxCursor + 4] = vtxCursor - 1;
indexData[idxCursor + 5] = vtxCursor - 2;
idxCursor += 6;
// There is no next vertex.
s.current = null;
}
// Upload data to the GPU.
gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer);
gl.bufferData(gl.ARRAY_BUFFER, vertexData, gl.STATIC_DRAW);
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indexData, gl.STATIC_DRAW);
// Record number of indices.
this.indexBufferSize = indexData.length;
}
});
// Subclass the layer view from GraphicsLayer, to take advantage of its
// watchable graphics property.
const CustomLayer = GraphicsLayer.createSubclass({
createLayerView: function(view){
if (view.type === "2d") {
return new CustomLayerView2D({
view: view,
layer: this
});
}
}
});
//-----------------
//--------------------------------------------
require([
"esri/Map",
"esri/layers/GeoJSONLayer",
"esri/views/MapView",
"esri/core/watchUtils"
], function(Map, GeoJSONLayer, MapView, watchUtils) {
const url = "https://raw.githubusercontent.com/gcwater/runing_line/main/Bookmar_GCWA.geojson";
const template = {
title: "Water Pump Info:",
content: "Pump Name: {ASSET_NAME}, Pump Location: {LOCATION_DESCRIPTION}",
fieldInfos: [
{
fieldName: "time",
format: {
dateFormat: "short-date-short-time"
}
}
]
};
const renderer = {
type: "simple",
field: "applicant_id",
symbol: {
type: "simple-marker",
color: "orange",
size: 10,
outline: {
color: "white"
}
}
};
const geojsonLayer = new GeoJSONLayer({
url: url,
//copyright: "USGS Earthquakes",
popupTemplate: template,
renderer: renderer //optional
});
const map = new Map({
basemap: "gray-vector",
layers: [geojsonLayer]
});
const view = new MapView({
container: "viewDiv",
map: map,
center: [-95.30, 29.45],
zoom: 10.75,
map: map
});
function changeMouseCursor(response)
{
if (response.results.length > 0) {
document.getElementById("viewDiv").style.cursor = "pointer";
} else {
document.getElementById("viewDiv").style.cursor = "default";
}
}
function getNewGraphics(response) {
view.graphics.removeAll();
if (response.results.length > 0) {
var graphic = response.results[0].graphic;
graphic.symbol =
{
type: "simple-marker",
style: "circle",
color: [ 17, 114, 212, 0.3 ],
outline:
{ // autocasts as new SimpleLineSymbol()
color: "blue",
width: 2
}
}
view.graphics.add(graphic);
}
}
view.when(function () {
view.whenLayerView(geojsonLayer).then(function (lview) {
watchUtils.whenFalseOnce(lview, "updating", function () {
// Set up a click event handler and retrieve the screen x, y coordinates
view.on("pointer-move", function (evt) {
var screenPoint = {
x: evt.x,
y: evt.y
};
view.hitTest(screenPoint)
.then(function (response) {
changeMouseCursor(response);
getNewGraphics(response);
});
});
});
});
});
//------------------
//Bookamark--------------
require([
"esri/Map",
"esri/views/MapView",
"esri/widgets/Bookmarks",
"esri/widgets/Expand",
"esri/core/Collection"
], function (Map, MapView, Bookmarks, Expand, Collection) {
const bookmarks = new Bookmarks({
view: view,
editingEnabled: true,
bookmarks: []
});
const bkExpand = new Expand({
view: view,
content: bookmarks,
expanded: true
})
const BOOKMARK_KEY = "arcgis-local-bookmarks-test";
const existingBookmarks = localStorage.getItem(BOOKMARK_KEY) || null;
if (existingBookmarks) {
console.log({'has existing bookark': existingBookmarks});
existingData = JSON.parse(existingBookmarks);
console.log({existingData});
bookmarks.bookmarks = existingData;
}
// Add the widget to the top-right corner of the view
view.ui.add(bkExpand, "bottom-left");
//view.ui.add(bookmarks, "bottom-left" );
//view.ui.add(bkExpand, "bottom-left");
bookmarks.bookmarks.on("after-add", function (event) {
const rawBookmarks = bookmarks.bookmarks.map(bm => bm.toJSON());
console.log(rawBookmarks);
localStorage.setItem(BOOKMARK_KEY, JSON.stringify(rawBookmarks));
existingData.push(rawBookmarks);
});
});
//-----------------------
esriRequest("https://raw.githubusercontent.com/gcwater/runing_line/main/all_canal_system.json", {
responseType: "json"
}).then((response) => {
const graphics = response.data.map((trip) => {
return {
attributes: {
"color": trip.color
},
geometry: webMercatorUtils.geographicToWebMercator({
paths: [trip.path],
type: "polyline",
spatialReference: {
wkid: 1000
}
})
};
});
//------------
require([
"esri/widgets/Sketch",
"esri/Map",
"esri/layers/GraphicsLayer",
"esri/views/MapView"
], (Sketch, Map, GraphicsLayer, MapView) => {
const graphicsLayer = new GraphicsLayer();
view.when(() => {
const sketch = new Sketch({
layer: graphicsLayer,
view: view,
// graphic will be selected as soon as it is created
creationMode: "update"
});
view.ui.add(sketch, "top-right");
});
});
//----------------------
require(["esri/Map", "esri/views/SceneView", "esri/widgets/Search"], (
Map,
SceneView,
Search
) => {
const searchWidget = new Search({
view: view
});
// Add the search widget to the top right corner of the view
view.ui.add(searchWidget, {
position: "top-right"
});
});
//--------------
require([
"esri/Map",
"esri/views/SceneView",
"esri/widgets/Expand",
"esri/widgets/BasemapGallery"
], (Map, SceneView, Expand, BasemapGallery) => {
const basemapGallery = new BasemapGallery({
view: view,
container: document.createElement("div")
});
// Create an Expand instance and set the content
// property to the DOM node of the basemap gallery widget
// Use an Esri icon font to represent the content inside
// of the Expand widget
const bgExpand = new Expand({
view: view,
content: basemapGallery
});
// close the expand whenever a basemap is selected
basemapGallery.watch("activeBasemap", () => {
const mobileSize =
view.heightBreakpoint === "xsmall" ||
view.widthBreakpoint === "xsmall";
if (mobileSize) {
bgExpand.collapse();
}
});
// Add the expand instance to the ui
view.ui.add(bgExpand, "top-right");
});
//-----------
//});
//--------------------------
require(["esri/Map", "esri/views/SceneView", "esri/widgets/Home", "esri/widgets/Fullscreen"
], (
Map,
SceneView,
Home,
Fullscreen
) => {
const homeBtn = new Home({
view: view
});
fullscreen = new Fullscreen({
view: view
});
// Add the home button to the top left corner of the view
view.ui.add(homeBtn, "top-left");
view.ui.add(fullscreen, 'top-left');
});
//-------------------------------
//----------------------------------
const layer = new CustomLayer({
graphics: graphics
});
//------------
//---------------------------
map.layers.add(layer);
});
});
// })
});
// });
</script>
</head>
<body>
<div id="viewDiv"></div>
<div id="viewDiv" class="viewDiv">
<div id="info" class="esri-widget">
<pre class="tab">GCWA Canal Flow Map</pre>
</div>
</div>
<div class="content">
<div>
</div>
</div>
</div>
<svg style="position:fixed; top:50vh">
<defs>
<filter id="blob">
<feGaussianBlur in="SourceGraphic" stdDeviation="5" result="blur"></feGaussianBlur>
<feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 19 -9" result="blob"></feColorMatrix>
<feComposite in="SourceGraphic" in2="blob" operator="atop"></feComposite>
</filter>
</defs>
</svg>
<div>