@corpsmap/corpsmap 3.2.34 → 3.2.35
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/lib/dev.js +192 -54
- package/lib/prod.js +192 -54
- package/package.json +1 -1
- package/src/core-plugins/legend/bundle.js +178 -8
package/lib/dev.js
CHANGED
|
@@ -106568,7 +106568,7 @@ var config = {
|
|
|
106568
106568
|
};
|
|
106569
106569
|
|
|
106570
106570
|
var name = "@corpsmap/corpsmap";
|
|
106571
|
-
var version$1 = "3.2.
|
|
106571
|
+
var version$1 = "3.2.35";
|
|
106572
106572
|
var description = "CorpsMap as React Components";
|
|
106573
106573
|
var main = "index.js";
|
|
106574
106574
|
var scripts = {
|
|
@@ -159405,8 +159405,7 @@ var bundle$8 = {
|
|
|
159405
159405
|
widths: [],
|
|
159406
159406
|
heights: []
|
|
159407
159407
|
};
|
|
159408
|
-
var src = url;
|
|
159409
|
-
debugger;
|
|
159408
|
+
var src = url; // debugger
|
|
159410
159409
|
|
|
159411
159410
|
switch (type) {
|
|
159412
159411
|
case "ArcGIS":
|
|
@@ -159428,8 +159427,9 @@ var bundle$8 = {
|
|
|
159428
159427
|
}
|
|
159429
159428
|
|
|
159430
159429
|
req = xhr.get(src, function (err, response, body) {
|
|
159430
|
+
// debugger
|
|
159431
159431
|
if (err || response.statusCode !== 200) {
|
|
159432
|
-
debugger
|
|
159432
|
+
// debugger
|
|
159433
159433
|
legendLayers[uid] = ["Legend not available!"];
|
|
159434
159434
|
dispatch({
|
|
159435
159435
|
type: "LEGEND_LAYERS_UPDATE_ERROR",
|
|
@@ -159441,8 +159441,8 @@ var bundle$8 = {
|
|
|
159441
159441
|
});
|
|
159442
159442
|
} else {
|
|
159443
159443
|
try {
|
|
159444
|
-
debugger
|
|
159445
|
-
|
|
159444
|
+
var data = JSON.parse(body); // debugger
|
|
159445
|
+
|
|
159446
159446
|
console.log(data);
|
|
159447
159447
|
|
|
159448
159448
|
if (type === "EsriFeatureService") {
|
|
@@ -159565,6 +159565,9 @@ var bundle$8 = {
|
|
|
159565
159565
|
};
|
|
159566
159566
|
legendLayers[uid] = []; //TODO Logic below is needs to include other Esri styles.
|
|
159567
159567
|
|
|
159568
|
+
console.log(drawingInfo.renderer);
|
|
159569
|
+
console.log(drawingInfo.renderer.symbol); // debugger
|
|
159570
|
+
|
|
159568
159571
|
switch (data.geometryType) {
|
|
159569
159572
|
case "esriGeometryPolygon":
|
|
159570
159573
|
if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriSFS" && drawingInfo.renderer.symbol.style === "esriSFSSolid") {
|
|
@@ -159606,7 +159609,67 @@ var bundle$8 = {
|
|
|
159606
159609
|
loading: false
|
|
159607
159610
|
}
|
|
159608
159611
|
});
|
|
159609
|
-
}
|
|
159612
|
+
} //__________________________________________________________________________________________________________________________________
|
|
159613
|
+
else if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriSFS" && drawingInfo.renderer.symbol.style === "esriSFSBackwardDiagonal") {
|
|
159614
|
+
// debugger
|
|
159615
|
+
var _img = new Image();
|
|
159616
|
+
|
|
159617
|
+
var _outlineColor = drawingInfo.renderer.symbol.outline.color;
|
|
159618
|
+
var _fillColor = drawingInfo.renderer.symbol.color;
|
|
159619
|
+
|
|
159620
|
+
var _canvas = document.createElement("canvas");
|
|
159621
|
+
|
|
159622
|
+
var _ctx = _canvas.getContext("2d");
|
|
159623
|
+
|
|
159624
|
+
_canvas.width = 20;
|
|
159625
|
+
_canvas.height = 20; //store width & height for larger canvas calculation
|
|
159626
|
+
|
|
159627
|
+
legendCanvases[uid].widths.push(_canvas.width);
|
|
159628
|
+
legendCanvases[uid].heights.push(_canvas.height); // // Draw polygon
|
|
159629
|
+
|
|
159630
|
+
_ctx.beginPath();
|
|
159631
|
+
|
|
159632
|
+
_ctx.moveTo(0, 10);
|
|
159633
|
+
|
|
159634
|
+
_ctx.lineTo(10, 0);
|
|
159635
|
+
|
|
159636
|
+
_ctx.moveTo(0, 20);
|
|
159637
|
+
|
|
159638
|
+
_ctx.lineTo(20, 0);
|
|
159639
|
+
|
|
159640
|
+
_ctx.moveTo(10, 20);
|
|
159641
|
+
|
|
159642
|
+
_ctx.lineTo(20, 10);
|
|
159643
|
+
|
|
159644
|
+
_ctx.lineWidth = "2";
|
|
159645
|
+
_ctx.strokeStyle = "rgba(".concat(_outlineColor.join(), ")");
|
|
159646
|
+
|
|
159647
|
+
_ctx.rect(0, 0, 20, 20);
|
|
159648
|
+
|
|
159649
|
+
_ctx.stroke();
|
|
159650
|
+
|
|
159651
|
+
_img.src = _canvas.toDataURL(); //set src using data URI from canvas
|
|
159652
|
+
|
|
159653
|
+
_img.alt = "Style for ".concat(displayName);
|
|
159654
|
+
_img.crossOrigin = "anonymous";
|
|
159655
|
+
legendCanvases[uid].canvas.push(_canvas);
|
|
159656
|
+
dispatch({
|
|
159657
|
+
type: "LEGEND_CANVAS_ADDED",
|
|
159658
|
+
payload: {
|
|
159659
|
+
legendCanvases: legendCanvases,
|
|
159660
|
+
loading: false
|
|
159661
|
+
}
|
|
159662
|
+
});
|
|
159663
|
+
legendLayers[uid].push(_img);
|
|
159664
|
+
dispatch({
|
|
159665
|
+
type: "LEGEND_LAYERS_UPDATED",
|
|
159666
|
+
payload: {
|
|
159667
|
+
legendLayers: legendLayers,
|
|
159668
|
+
loading: false
|
|
159669
|
+
}
|
|
159670
|
+
});
|
|
159671
|
+
} //____________________________________________________________________________________________________________________________________
|
|
159672
|
+
else if (drawingInfo.renderer.type === "uniqueValue" && drawingInfo.renderer.uniqueValueInfos) {
|
|
159610
159673
|
drawingInfo.renderer.uniqueValueInfos.forEach(function (val) {
|
|
159611
159674
|
var img = new Image();
|
|
159612
159675
|
var outlineColor = val.symbol.outline.color;
|
|
@@ -159659,35 +159722,35 @@ var bundle$8 = {
|
|
|
159659
159722
|
|
|
159660
159723
|
case "esriGeometryPolyline":
|
|
159661
159724
|
if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriSLS" && drawingInfo.renderer.symbol.style === "esriSLSSolid") {
|
|
159662
|
-
var
|
|
159725
|
+
var _img2 = new Image();
|
|
159663
159726
|
|
|
159664
|
-
var
|
|
159727
|
+
var _canvas2 = document.createElement("canvas");
|
|
159665
159728
|
|
|
159666
|
-
var
|
|
159729
|
+
var _ctx2 = _canvas2.getContext("2d");
|
|
159667
159730
|
|
|
159668
159731
|
var lineColor = drawingInfo.renderer.symbol.color;
|
|
159669
|
-
|
|
159670
|
-
|
|
159732
|
+
_canvas2.width = 20;
|
|
159733
|
+
_canvas2.height = 20; //store width & height for larger canvas calculation
|
|
159671
159734
|
|
|
159672
|
-
legendCanvases[uid].widths.push(
|
|
159673
|
-
legendCanvases[uid].heights.push(
|
|
159735
|
+
legendCanvases[uid].widths.push(_canvas2.width);
|
|
159736
|
+
legendCanvases[uid].heights.push(_canvas2.height); // Draw line
|
|
159674
159737
|
|
|
159675
|
-
|
|
159738
|
+
_ctx2.beginPath();
|
|
159676
159739
|
|
|
159677
|
-
|
|
159740
|
+
_ctx2.strokeStyle = "rgba(".concat(lineColor.join(), ")");
|
|
159678
159741
|
|
|
159679
|
-
|
|
159742
|
+
_ctx2.moveTo(0, 0);
|
|
159680
159743
|
|
|
159681
|
-
|
|
159744
|
+
_ctx2.lineTo(20, 20);
|
|
159682
159745
|
|
|
159683
|
-
|
|
159746
|
+
_ctx2.stroke(); //set img attributes
|
|
159684
159747
|
|
|
159685
159748
|
|
|
159686
|
-
|
|
159749
|
+
_img2.src = _canvas2.toDataURL(); //set src using data URI from canvas
|
|
159687
159750
|
|
|
159688
|
-
|
|
159689
|
-
|
|
159690
|
-
legendCanvases[uid].canvas.push(
|
|
159751
|
+
_img2.alt = "Style for ".concat(displayName);
|
|
159752
|
+
_img2.crossOrigin = "anonymous";
|
|
159753
|
+
legendCanvases[uid].canvas.push(_canvas2);
|
|
159691
159754
|
dispatch({
|
|
159692
159755
|
type: "LEGEND_CANVAS_ADDED",
|
|
159693
159756
|
payload: {
|
|
@@ -159695,7 +159758,7 @@ var bundle$8 = {
|
|
|
159695
159758
|
loading: false
|
|
159696
159759
|
}
|
|
159697
159760
|
});
|
|
159698
|
-
legendLayers[uid].push(
|
|
159761
|
+
legendLayers[uid].push(_img2);
|
|
159699
159762
|
dispatch({
|
|
159700
159763
|
type: "LEGEND_LAYERS_UPDATED",
|
|
159701
159764
|
payload: {
|
|
@@ -159752,12 +159815,12 @@ var bundle$8 = {
|
|
|
159752
159815
|
break;
|
|
159753
159816
|
|
|
159754
159817
|
case "esriGeometryPoint":
|
|
159755
|
-
if (drawingInfo.renderer.symbol.type === "esriPMS") {
|
|
159756
|
-
var
|
|
159818
|
+
if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriPMS") {
|
|
159819
|
+
var _img3 = new Image();
|
|
159757
159820
|
|
|
159758
|
-
|
|
159821
|
+
_img3.src = "data:image/png;base64,".concat(data.drawingInfo.renderer.symbol.imageData);
|
|
159759
159822
|
|
|
159760
|
-
|
|
159823
|
+
_img3.addEventListener("load", function () {
|
|
159761
159824
|
var canvas = document.createElement("canvas");
|
|
159762
159825
|
var ctx = canvas.getContext("2d");
|
|
159763
159826
|
canvas.width = drawingInfo.renderer.symbol.width;
|
|
@@ -159768,7 +159831,7 @@ var bundle$8 = {
|
|
|
159768
159831
|
|
|
159769
159832
|
ctx.fillStyle = "white";
|
|
159770
159833
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
159771
|
-
ctx.drawImage(
|
|
159834
|
+
ctx.drawImage(_img3, 0, 0); //add image to canvas
|
|
159772
159835
|
|
|
159773
159836
|
legendCanvases[uid].canvas.push(canvas);
|
|
159774
159837
|
dispatch({
|
|
@@ -159780,9 +159843,9 @@ var bundle$8 = {
|
|
|
159780
159843
|
});
|
|
159781
159844
|
}, false);
|
|
159782
159845
|
|
|
159783
|
-
|
|
159784
|
-
|
|
159785
|
-
legendLayers[uid] = [
|
|
159846
|
+
_img3.alt = "Style for ".concat(displayName);
|
|
159847
|
+
_img3.crossOrigin = "anonymous";
|
|
159848
|
+
legendLayers[uid] = [_img3]; //TODO: Update to possibly push multiple images into array
|
|
159786
159849
|
|
|
159787
159850
|
dispatch({
|
|
159788
159851
|
type: "LEGEND_LAYERS_UPDATED",
|
|
@@ -159790,41 +159853,41 @@ var bundle$8 = {
|
|
|
159790
159853
|
legendLayers: legendLayers
|
|
159791
159854
|
}
|
|
159792
159855
|
});
|
|
159793
|
-
} else if (drawingInfo.renderer.symbol.type === "esriSMS") {
|
|
159794
|
-
var
|
|
159856
|
+
} else if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriSMS") {
|
|
159857
|
+
var _img4 = new Image();
|
|
159795
159858
|
|
|
159796
|
-
var
|
|
159859
|
+
var _outlineColor2 = drawingInfo.renderer.symbol.outline.color;
|
|
159797
159860
|
var outlineWidth = drawingInfo.renderer.symbol.outline.width;
|
|
159798
|
-
var
|
|
159861
|
+
var _fillColor2 = drawingInfo.renderer.symbol.color;
|
|
159799
159862
|
var size = drawingInfo.renderer.symbol.size;
|
|
159800
159863
|
|
|
159801
|
-
var
|
|
159864
|
+
var _canvas3 = document.createElement("canvas");
|
|
159802
159865
|
|
|
159803
|
-
var
|
|
159866
|
+
var _ctx3 = _canvas3.getContext("2d");
|
|
159804
159867
|
|
|
159805
|
-
|
|
159806
|
-
|
|
159807
|
-
legendCanvases[uid].widths.push(
|
|
159808
|
-
legendCanvases[uid].heights.push(
|
|
159868
|
+
_canvas3.width = 20;
|
|
159869
|
+
_canvas3.height = 20;
|
|
159870
|
+
legendCanvases[uid].widths.push(_canvas3.width);
|
|
159871
|
+
legendCanvases[uid].heights.push(_canvas3.height); // circle
|
|
159809
159872
|
|
|
159810
|
-
|
|
159873
|
+
_ctx3.beginPath();
|
|
159811
159874
|
|
|
159812
|
-
|
|
159813
|
-
|
|
159875
|
+
_ctx3.strokeStyle = "rgba(".concat(_outlineColor2.join(), ")");
|
|
159876
|
+
_ctx3.lineWidth = outlineWidth;
|
|
159814
159877
|
|
|
159815
|
-
|
|
159878
|
+
_ctx3.arc(size, size, size / 1.5, 0, Math.PI * 2);
|
|
159816
159879
|
|
|
159817
|
-
|
|
159880
|
+
_ctx3.fillStyle = "rgba(".concat(_fillColor2.join(), ")");
|
|
159818
159881
|
|
|
159819
|
-
|
|
159882
|
+
_ctx3.fill();
|
|
159820
159883
|
|
|
159821
|
-
|
|
159884
|
+
_ctx3.stroke();
|
|
159822
159885
|
|
|
159823
|
-
|
|
159886
|
+
_img4.src = _canvas3.toDataURL(); //set src using data URI from canvas
|
|
159824
159887
|
|
|
159825
|
-
|
|
159826
|
-
|
|
159827
|
-
legendCanvases[uid].canvas.push(
|
|
159888
|
+
_img4.alt = "Style for ".concat(displayName);
|
|
159889
|
+
_img4.crossOrigin = "anonymous";
|
|
159890
|
+
legendCanvases[uid].canvas.push(_canvas3);
|
|
159828
159891
|
dispatch({
|
|
159829
159892
|
type: "LEGEND_CANVAS_ADDED",
|
|
159830
159893
|
payload: {
|
|
@@ -159832,7 +159895,7 @@ var bundle$8 = {
|
|
|
159832
159895
|
loading: false
|
|
159833
159896
|
}
|
|
159834
159897
|
});
|
|
159835
|
-
legendLayers[uid].push(
|
|
159898
|
+
legendLayers[uid].push(_img4);
|
|
159836
159899
|
dispatch({
|
|
159837
159900
|
type: "LEGEND_LAYERS_UPDATED",
|
|
159838
159901
|
payload: {
|
|
@@ -159840,6 +159903,81 @@ var bundle$8 = {
|
|
|
159840
159903
|
loading: false
|
|
159841
159904
|
}
|
|
159842
159905
|
});
|
|
159906
|
+
} //___________________________________________________________________________________________________________________________________
|
|
159907
|
+
else if (drawingInfo.renderer.uniqueValueInfos) {
|
|
159908
|
+
// let canvas = document.createElement("canvas");
|
|
159909
|
+
// let ctx = canvas.getContext("2d");
|
|
159910
|
+
var result = [];
|
|
159911
|
+
drawingInfo.renderer.uniqueValueInfos.forEach(function (val) {
|
|
159912
|
+
var label = val.label;
|
|
159913
|
+
var img = new Image();
|
|
159914
|
+
img.src = "data:image/png;base64,".concat(val.symbol.imageData); // img.addEventListener(
|
|
159915
|
+
// "load",
|
|
159916
|
+
// function () {
|
|
159917
|
+
|
|
159918
|
+
var canvas = document.createElement("canvas");
|
|
159919
|
+
var ctx = canvas.getContext("2d");
|
|
159920
|
+
var labelWidth = Number(ctx.measureText(label).width); //set canvas width & height
|
|
159921
|
+
|
|
159922
|
+
canvas.width = Number(val.symbol.width) + labelWidth + 4;
|
|
159923
|
+
canvas.height = val.symbol.height; //store width & height for larger canvas calculation
|
|
159924
|
+
// legendCanvases[uid].widths.push(canvas.width);
|
|
159925
|
+
// legendCanvases[uid].heights.push(canvas.height);
|
|
159926
|
+
//set background
|
|
159927
|
+
|
|
159928
|
+
ctx.fillStyle = "white";
|
|
159929
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height); // // ctx.putImageData(val.symbol.imageData, 0,0)
|
|
159930
|
+
|
|
159931
|
+
ctx.drawImage(img, 0, 0); //add image to canvas
|
|
159932
|
+
// //add label to the right of image
|
|
159933
|
+
// ctx.font = "10px Arial";
|
|
159934
|
+
// ctx.fillStyle = "black";
|
|
159935
|
+
// ctx.fillText(label, canvas.width + 2, canvas.height / 2);
|
|
159936
|
+
// legendCanvases[uid].canvas.push(canvas);
|
|
159937
|
+
// dispatch({
|
|
159938
|
+
// type: "LEGEND_CANVAS_ADDED",
|
|
159939
|
+
// payload: {
|
|
159940
|
+
// legendCanvases: legendCanvases,
|
|
159941
|
+
// loading: false,
|
|
159942
|
+
// },
|
|
159943
|
+
// });
|
|
159944
|
+
// result.push(canvas)
|
|
159945
|
+
// },
|
|
159946
|
+
// false
|
|
159947
|
+
// );
|
|
159948
|
+
// img.src = `data:${val.symbol.url};base64,${val.symbol.imageData}`
|
|
159949
|
+
// img.src = canvas.toDataURL()
|
|
159950
|
+
|
|
159951
|
+
img.alt = "Style for ".concat(label);
|
|
159952
|
+
img.crossOrigin = "anonymous";
|
|
159953
|
+
img.title = label; // legendLayers[uid] = [img]; //TODO: Update to possibly push multiple images into array
|
|
159954
|
+
// images.push(img)
|
|
159955
|
+
// dispatch({
|
|
159956
|
+
// type: "LEGEND_LAYERS_UPDATED",
|
|
159957
|
+
// payload: {
|
|
159958
|
+
// legendLayers: legendLayers,
|
|
159959
|
+
// },
|
|
159960
|
+
// });
|
|
159961
|
+
|
|
159962
|
+
result.push({
|
|
159963
|
+
canvas: canvas,
|
|
159964
|
+
image: img
|
|
159965
|
+
});
|
|
159966
|
+
});
|
|
159967
|
+
result.forEach(function (item) {
|
|
159968
|
+
item.image.alt = "Style for ".concat(lyr.displayName);
|
|
159969
|
+
legendCanvases[lyr.uid].widths.push(item.canvas.width);
|
|
159970
|
+
legendCanvases[lyr.uid].heights.push(item.canvas.height);
|
|
159971
|
+
legendCanvases[lyr.uid].canvas.push(item.canvas);
|
|
159972
|
+
legendLayers[lyr.uid].push(item.image);
|
|
159973
|
+
dispatch({
|
|
159974
|
+
type: "LEGEND_CANVAS_ADDED",
|
|
159975
|
+
payload: {
|
|
159976
|
+
legendCanvases: legendCanvases,
|
|
159977
|
+
loading: false
|
|
159978
|
+
}
|
|
159979
|
+
});
|
|
159980
|
+
});
|
|
159843
159981
|
} else {
|
|
159844
159982
|
legendLayers[uid] = ["Legend not available!"];
|
|
159845
159983
|
dispatch({
|
package/lib/prod.js
CHANGED
|
@@ -106482,7 +106482,7 @@ var config = {
|
|
|
106482
106482
|
};
|
|
106483
106483
|
|
|
106484
106484
|
var name = "@corpsmap/corpsmap";
|
|
106485
|
-
var version$1 = "3.2.
|
|
106485
|
+
var version$1 = "3.2.35";
|
|
106486
106486
|
var description = "CorpsMap as React Components";
|
|
106487
106487
|
var main = "index.js";
|
|
106488
106488
|
var scripts = {
|
|
@@ -159319,8 +159319,7 @@ var bundle$8 = {
|
|
|
159319
159319
|
widths: [],
|
|
159320
159320
|
heights: []
|
|
159321
159321
|
};
|
|
159322
|
-
var src = url;
|
|
159323
|
-
debugger;
|
|
159322
|
+
var src = url; // debugger
|
|
159324
159323
|
|
|
159325
159324
|
switch (type) {
|
|
159326
159325
|
case "ArcGIS":
|
|
@@ -159342,8 +159341,9 @@ var bundle$8 = {
|
|
|
159342
159341
|
}
|
|
159343
159342
|
|
|
159344
159343
|
req = xhr.get(src, function (err, response, body) {
|
|
159344
|
+
// debugger
|
|
159345
159345
|
if (err || response.statusCode !== 200) {
|
|
159346
|
-
debugger
|
|
159346
|
+
// debugger
|
|
159347
159347
|
legendLayers[uid] = ["Legend not available!"];
|
|
159348
159348
|
dispatch({
|
|
159349
159349
|
type: "LEGEND_LAYERS_UPDATE_ERROR",
|
|
@@ -159355,8 +159355,8 @@ var bundle$8 = {
|
|
|
159355
159355
|
});
|
|
159356
159356
|
} else {
|
|
159357
159357
|
try {
|
|
159358
|
-
debugger
|
|
159359
|
-
|
|
159358
|
+
var data = JSON.parse(body); // debugger
|
|
159359
|
+
|
|
159360
159360
|
console.log(data);
|
|
159361
159361
|
|
|
159362
159362
|
if (type === "EsriFeatureService") {
|
|
@@ -159479,6 +159479,9 @@ var bundle$8 = {
|
|
|
159479
159479
|
};
|
|
159480
159480
|
legendLayers[uid] = []; //TODO Logic below is needs to include other Esri styles.
|
|
159481
159481
|
|
|
159482
|
+
console.log(drawingInfo.renderer);
|
|
159483
|
+
console.log(drawingInfo.renderer.symbol); // debugger
|
|
159484
|
+
|
|
159482
159485
|
switch (data.geometryType) {
|
|
159483
159486
|
case "esriGeometryPolygon":
|
|
159484
159487
|
if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriSFS" && drawingInfo.renderer.symbol.style === "esriSFSSolid") {
|
|
@@ -159520,7 +159523,67 @@ var bundle$8 = {
|
|
|
159520
159523
|
loading: false
|
|
159521
159524
|
}
|
|
159522
159525
|
});
|
|
159523
|
-
}
|
|
159526
|
+
} //__________________________________________________________________________________________________________________________________
|
|
159527
|
+
else if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriSFS" && drawingInfo.renderer.symbol.style === "esriSFSBackwardDiagonal") {
|
|
159528
|
+
// debugger
|
|
159529
|
+
var _img = new Image();
|
|
159530
|
+
|
|
159531
|
+
var _outlineColor = drawingInfo.renderer.symbol.outline.color;
|
|
159532
|
+
var _fillColor = drawingInfo.renderer.symbol.color;
|
|
159533
|
+
|
|
159534
|
+
var _canvas = document.createElement("canvas");
|
|
159535
|
+
|
|
159536
|
+
var _ctx = _canvas.getContext("2d");
|
|
159537
|
+
|
|
159538
|
+
_canvas.width = 20;
|
|
159539
|
+
_canvas.height = 20; //store width & height for larger canvas calculation
|
|
159540
|
+
|
|
159541
|
+
legendCanvases[uid].widths.push(_canvas.width);
|
|
159542
|
+
legendCanvases[uid].heights.push(_canvas.height); // // Draw polygon
|
|
159543
|
+
|
|
159544
|
+
_ctx.beginPath();
|
|
159545
|
+
|
|
159546
|
+
_ctx.moveTo(0, 10);
|
|
159547
|
+
|
|
159548
|
+
_ctx.lineTo(10, 0);
|
|
159549
|
+
|
|
159550
|
+
_ctx.moveTo(0, 20);
|
|
159551
|
+
|
|
159552
|
+
_ctx.lineTo(20, 0);
|
|
159553
|
+
|
|
159554
|
+
_ctx.moveTo(10, 20);
|
|
159555
|
+
|
|
159556
|
+
_ctx.lineTo(20, 10);
|
|
159557
|
+
|
|
159558
|
+
_ctx.lineWidth = "2";
|
|
159559
|
+
_ctx.strokeStyle = "rgba(".concat(_outlineColor.join(), ")");
|
|
159560
|
+
|
|
159561
|
+
_ctx.rect(0, 0, 20, 20);
|
|
159562
|
+
|
|
159563
|
+
_ctx.stroke();
|
|
159564
|
+
|
|
159565
|
+
_img.src = _canvas.toDataURL(); //set src using data URI from canvas
|
|
159566
|
+
|
|
159567
|
+
_img.alt = "Style for ".concat(displayName);
|
|
159568
|
+
_img.crossOrigin = "anonymous";
|
|
159569
|
+
legendCanvases[uid].canvas.push(_canvas);
|
|
159570
|
+
dispatch({
|
|
159571
|
+
type: "LEGEND_CANVAS_ADDED",
|
|
159572
|
+
payload: {
|
|
159573
|
+
legendCanvases: legendCanvases,
|
|
159574
|
+
loading: false
|
|
159575
|
+
}
|
|
159576
|
+
});
|
|
159577
|
+
legendLayers[uid].push(_img);
|
|
159578
|
+
dispatch({
|
|
159579
|
+
type: "LEGEND_LAYERS_UPDATED",
|
|
159580
|
+
payload: {
|
|
159581
|
+
legendLayers: legendLayers,
|
|
159582
|
+
loading: false
|
|
159583
|
+
}
|
|
159584
|
+
});
|
|
159585
|
+
} //____________________________________________________________________________________________________________________________________
|
|
159586
|
+
else if (drawingInfo.renderer.type === "uniqueValue" && drawingInfo.renderer.uniqueValueInfos) {
|
|
159524
159587
|
drawingInfo.renderer.uniqueValueInfos.forEach(function (val) {
|
|
159525
159588
|
var img = new Image();
|
|
159526
159589
|
var outlineColor = val.symbol.outline.color;
|
|
@@ -159573,35 +159636,35 @@ var bundle$8 = {
|
|
|
159573
159636
|
|
|
159574
159637
|
case "esriGeometryPolyline":
|
|
159575
159638
|
if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriSLS" && drawingInfo.renderer.symbol.style === "esriSLSSolid") {
|
|
159576
|
-
var
|
|
159639
|
+
var _img2 = new Image();
|
|
159577
159640
|
|
|
159578
|
-
var
|
|
159641
|
+
var _canvas2 = document.createElement("canvas");
|
|
159579
159642
|
|
|
159580
|
-
var
|
|
159643
|
+
var _ctx2 = _canvas2.getContext("2d");
|
|
159581
159644
|
|
|
159582
159645
|
var lineColor = drawingInfo.renderer.symbol.color;
|
|
159583
|
-
|
|
159584
|
-
|
|
159646
|
+
_canvas2.width = 20;
|
|
159647
|
+
_canvas2.height = 20; //store width & height for larger canvas calculation
|
|
159585
159648
|
|
|
159586
|
-
legendCanvases[uid].widths.push(
|
|
159587
|
-
legendCanvases[uid].heights.push(
|
|
159649
|
+
legendCanvases[uid].widths.push(_canvas2.width);
|
|
159650
|
+
legendCanvases[uid].heights.push(_canvas2.height); // Draw line
|
|
159588
159651
|
|
|
159589
|
-
|
|
159652
|
+
_ctx2.beginPath();
|
|
159590
159653
|
|
|
159591
|
-
|
|
159654
|
+
_ctx2.strokeStyle = "rgba(".concat(lineColor.join(), ")");
|
|
159592
159655
|
|
|
159593
|
-
|
|
159656
|
+
_ctx2.moveTo(0, 0);
|
|
159594
159657
|
|
|
159595
|
-
|
|
159658
|
+
_ctx2.lineTo(20, 20);
|
|
159596
159659
|
|
|
159597
|
-
|
|
159660
|
+
_ctx2.stroke(); //set img attributes
|
|
159598
159661
|
|
|
159599
159662
|
|
|
159600
|
-
|
|
159663
|
+
_img2.src = _canvas2.toDataURL(); //set src using data URI from canvas
|
|
159601
159664
|
|
|
159602
|
-
|
|
159603
|
-
|
|
159604
|
-
legendCanvases[uid].canvas.push(
|
|
159665
|
+
_img2.alt = "Style for ".concat(displayName);
|
|
159666
|
+
_img2.crossOrigin = "anonymous";
|
|
159667
|
+
legendCanvases[uid].canvas.push(_canvas2);
|
|
159605
159668
|
dispatch({
|
|
159606
159669
|
type: "LEGEND_CANVAS_ADDED",
|
|
159607
159670
|
payload: {
|
|
@@ -159609,7 +159672,7 @@ var bundle$8 = {
|
|
|
159609
159672
|
loading: false
|
|
159610
159673
|
}
|
|
159611
159674
|
});
|
|
159612
|
-
legendLayers[uid].push(
|
|
159675
|
+
legendLayers[uid].push(_img2);
|
|
159613
159676
|
dispatch({
|
|
159614
159677
|
type: "LEGEND_LAYERS_UPDATED",
|
|
159615
159678
|
payload: {
|
|
@@ -159666,12 +159729,12 @@ var bundle$8 = {
|
|
|
159666
159729
|
break;
|
|
159667
159730
|
|
|
159668
159731
|
case "esriGeometryPoint":
|
|
159669
|
-
if (drawingInfo.renderer.symbol.type === "esriPMS") {
|
|
159670
|
-
var
|
|
159732
|
+
if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriPMS") {
|
|
159733
|
+
var _img3 = new Image();
|
|
159671
159734
|
|
|
159672
|
-
|
|
159735
|
+
_img3.src = "data:image/png;base64,".concat(data.drawingInfo.renderer.symbol.imageData);
|
|
159673
159736
|
|
|
159674
|
-
|
|
159737
|
+
_img3.addEventListener("load", function () {
|
|
159675
159738
|
var canvas = document.createElement("canvas");
|
|
159676
159739
|
var ctx = canvas.getContext("2d");
|
|
159677
159740
|
canvas.width = drawingInfo.renderer.symbol.width;
|
|
@@ -159682,7 +159745,7 @@ var bundle$8 = {
|
|
|
159682
159745
|
|
|
159683
159746
|
ctx.fillStyle = "white";
|
|
159684
159747
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
159685
|
-
ctx.drawImage(
|
|
159748
|
+
ctx.drawImage(_img3, 0, 0); //add image to canvas
|
|
159686
159749
|
|
|
159687
159750
|
legendCanvases[uid].canvas.push(canvas);
|
|
159688
159751
|
dispatch({
|
|
@@ -159694,9 +159757,9 @@ var bundle$8 = {
|
|
|
159694
159757
|
});
|
|
159695
159758
|
}, false);
|
|
159696
159759
|
|
|
159697
|
-
|
|
159698
|
-
|
|
159699
|
-
legendLayers[uid] = [
|
|
159760
|
+
_img3.alt = "Style for ".concat(displayName);
|
|
159761
|
+
_img3.crossOrigin = "anonymous";
|
|
159762
|
+
legendLayers[uid] = [_img3]; //TODO: Update to possibly push multiple images into array
|
|
159700
159763
|
|
|
159701
159764
|
dispatch({
|
|
159702
159765
|
type: "LEGEND_LAYERS_UPDATED",
|
|
@@ -159704,41 +159767,41 @@ var bundle$8 = {
|
|
|
159704
159767
|
legendLayers: legendLayers
|
|
159705
159768
|
}
|
|
159706
159769
|
});
|
|
159707
|
-
} else if (drawingInfo.renderer.symbol.type === "esriSMS") {
|
|
159708
|
-
var
|
|
159770
|
+
} else if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriSMS") {
|
|
159771
|
+
var _img4 = new Image();
|
|
159709
159772
|
|
|
159710
|
-
var
|
|
159773
|
+
var _outlineColor2 = drawingInfo.renderer.symbol.outline.color;
|
|
159711
159774
|
var outlineWidth = drawingInfo.renderer.symbol.outline.width;
|
|
159712
|
-
var
|
|
159775
|
+
var _fillColor2 = drawingInfo.renderer.symbol.color;
|
|
159713
159776
|
var size = drawingInfo.renderer.symbol.size;
|
|
159714
159777
|
|
|
159715
|
-
var
|
|
159778
|
+
var _canvas3 = document.createElement("canvas");
|
|
159716
159779
|
|
|
159717
|
-
var
|
|
159780
|
+
var _ctx3 = _canvas3.getContext("2d");
|
|
159718
159781
|
|
|
159719
|
-
|
|
159720
|
-
|
|
159721
|
-
legendCanvases[uid].widths.push(
|
|
159722
|
-
legendCanvases[uid].heights.push(
|
|
159782
|
+
_canvas3.width = 20;
|
|
159783
|
+
_canvas3.height = 20;
|
|
159784
|
+
legendCanvases[uid].widths.push(_canvas3.width);
|
|
159785
|
+
legendCanvases[uid].heights.push(_canvas3.height); // circle
|
|
159723
159786
|
|
|
159724
|
-
|
|
159787
|
+
_ctx3.beginPath();
|
|
159725
159788
|
|
|
159726
|
-
|
|
159727
|
-
|
|
159789
|
+
_ctx3.strokeStyle = "rgba(".concat(_outlineColor2.join(), ")");
|
|
159790
|
+
_ctx3.lineWidth = outlineWidth;
|
|
159728
159791
|
|
|
159729
|
-
|
|
159792
|
+
_ctx3.arc(size, size, size / 1.5, 0, Math.PI * 2);
|
|
159730
159793
|
|
|
159731
|
-
|
|
159794
|
+
_ctx3.fillStyle = "rgba(".concat(_fillColor2.join(), ")");
|
|
159732
159795
|
|
|
159733
|
-
|
|
159796
|
+
_ctx3.fill();
|
|
159734
159797
|
|
|
159735
|
-
|
|
159798
|
+
_ctx3.stroke();
|
|
159736
159799
|
|
|
159737
|
-
|
|
159800
|
+
_img4.src = _canvas3.toDataURL(); //set src using data URI from canvas
|
|
159738
159801
|
|
|
159739
|
-
|
|
159740
|
-
|
|
159741
|
-
legendCanvases[uid].canvas.push(
|
|
159802
|
+
_img4.alt = "Style for ".concat(displayName);
|
|
159803
|
+
_img4.crossOrigin = "anonymous";
|
|
159804
|
+
legendCanvases[uid].canvas.push(_canvas3);
|
|
159742
159805
|
dispatch({
|
|
159743
159806
|
type: "LEGEND_CANVAS_ADDED",
|
|
159744
159807
|
payload: {
|
|
@@ -159746,7 +159809,7 @@ var bundle$8 = {
|
|
|
159746
159809
|
loading: false
|
|
159747
159810
|
}
|
|
159748
159811
|
});
|
|
159749
|
-
legendLayers[uid].push(
|
|
159812
|
+
legendLayers[uid].push(_img4);
|
|
159750
159813
|
dispatch({
|
|
159751
159814
|
type: "LEGEND_LAYERS_UPDATED",
|
|
159752
159815
|
payload: {
|
|
@@ -159754,6 +159817,81 @@ var bundle$8 = {
|
|
|
159754
159817
|
loading: false
|
|
159755
159818
|
}
|
|
159756
159819
|
});
|
|
159820
|
+
} //___________________________________________________________________________________________________________________________________
|
|
159821
|
+
else if (drawingInfo.renderer.uniqueValueInfos) {
|
|
159822
|
+
// let canvas = document.createElement("canvas");
|
|
159823
|
+
// let ctx = canvas.getContext("2d");
|
|
159824
|
+
var result = [];
|
|
159825
|
+
drawingInfo.renderer.uniqueValueInfos.forEach(function (val) {
|
|
159826
|
+
var label = val.label;
|
|
159827
|
+
var img = new Image();
|
|
159828
|
+
img.src = "data:image/png;base64,".concat(val.symbol.imageData); // img.addEventListener(
|
|
159829
|
+
// "load",
|
|
159830
|
+
// function () {
|
|
159831
|
+
|
|
159832
|
+
var canvas = document.createElement("canvas");
|
|
159833
|
+
var ctx = canvas.getContext("2d");
|
|
159834
|
+
var labelWidth = Number(ctx.measureText(label).width); //set canvas width & height
|
|
159835
|
+
|
|
159836
|
+
canvas.width = Number(val.symbol.width) + labelWidth + 4;
|
|
159837
|
+
canvas.height = val.symbol.height; //store width & height for larger canvas calculation
|
|
159838
|
+
// legendCanvases[uid].widths.push(canvas.width);
|
|
159839
|
+
// legendCanvases[uid].heights.push(canvas.height);
|
|
159840
|
+
//set background
|
|
159841
|
+
|
|
159842
|
+
ctx.fillStyle = "white";
|
|
159843
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height); // // ctx.putImageData(val.symbol.imageData, 0,0)
|
|
159844
|
+
|
|
159845
|
+
ctx.drawImage(img, 0, 0); //add image to canvas
|
|
159846
|
+
// //add label to the right of image
|
|
159847
|
+
// ctx.font = "10px Arial";
|
|
159848
|
+
// ctx.fillStyle = "black";
|
|
159849
|
+
// ctx.fillText(label, canvas.width + 2, canvas.height / 2);
|
|
159850
|
+
// legendCanvases[uid].canvas.push(canvas);
|
|
159851
|
+
// dispatch({
|
|
159852
|
+
// type: "LEGEND_CANVAS_ADDED",
|
|
159853
|
+
// payload: {
|
|
159854
|
+
// legendCanvases: legendCanvases,
|
|
159855
|
+
// loading: false,
|
|
159856
|
+
// },
|
|
159857
|
+
// });
|
|
159858
|
+
// result.push(canvas)
|
|
159859
|
+
// },
|
|
159860
|
+
// false
|
|
159861
|
+
// );
|
|
159862
|
+
// img.src = `data:${val.symbol.url};base64,${val.symbol.imageData}`
|
|
159863
|
+
// img.src = canvas.toDataURL()
|
|
159864
|
+
|
|
159865
|
+
img.alt = "Style for ".concat(label);
|
|
159866
|
+
img.crossOrigin = "anonymous";
|
|
159867
|
+
img.title = label; // legendLayers[uid] = [img]; //TODO: Update to possibly push multiple images into array
|
|
159868
|
+
// images.push(img)
|
|
159869
|
+
// dispatch({
|
|
159870
|
+
// type: "LEGEND_LAYERS_UPDATED",
|
|
159871
|
+
// payload: {
|
|
159872
|
+
// legendLayers: legendLayers,
|
|
159873
|
+
// },
|
|
159874
|
+
// });
|
|
159875
|
+
|
|
159876
|
+
result.push({
|
|
159877
|
+
canvas: canvas,
|
|
159878
|
+
image: img
|
|
159879
|
+
});
|
|
159880
|
+
});
|
|
159881
|
+
result.forEach(function (item) {
|
|
159882
|
+
item.image.alt = "Style for ".concat(lyr.displayName);
|
|
159883
|
+
legendCanvases[lyr.uid].widths.push(item.canvas.width);
|
|
159884
|
+
legendCanvases[lyr.uid].heights.push(item.canvas.height);
|
|
159885
|
+
legendCanvases[lyr.uid].canvas.push(item.canvas);
|
|
159886
|
+
legendLayers[lyr.uid].push(item.image);
|
|
159887
|
+
dispatch({
|
|
159888
|
+
type: "LEGEND_CANVAS_ADDED",
|
|
159889
|
+
payload: {
|
|
159890
|
+
legendCanvases: legendCanvases,
|
|
159891
|
+
loading: false
|
|
159892
|
+
}
|
|
159893
|
+
});
|
|
159894
|
+
});
|
|
159757
159895
|
} else {
|
|
159758
159896
|
legendLayers[uid] = ["Legend not available!"];
|
|
159759
159897
|
dispatch({
|
package/package.json
CHANGED
|
@@ -49,7 +49,7 @@ export default {
|
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
let src = url;
|
|
52
|
-
debugger
|
|
52
|
+
// debugger
|
|
53
53
|
switch (type) {
|
|
54
54
|
case "ArcGIS":
|
|
55
55
|
src = `${src}/legend?f=pjson`;
|
|
@@ -57,7 +57,7 @@ export default {
|
|
|
57
57
|
case "ArcGISImage":
|
|
58
58
|
src = `${src}/legend?bandIds=&renderingRule=&f=pjson`;
|
|
59
59
|
break;
|
|
60
|
-
case "EsriFeatureService":
|
|
60
|
+
case "EsriFeatureService":
|
|
61
61
|
if (legendOverride === true) {
|
|
62
62
|
src = `${src}/legend?f=pjson`;
|
|
63
63
|
}
|
|
@@ -69,8 +69,9 @@ export default {
|
|
|
69
69
|
break;
|
|
70
70
|
}
|
|
71
71
|
req = xhr.get(src, (err, response, body) => {
|
|
72
|
+
// debugger
|
|
72
73
|
if (err || response.statusCode !== 200) {
|
|
73
|
-
debugger
|
|
74
|
+
// debugger
|
|
74
75
|
legendLayers[uid] = ["Legend not available!"];
|
|
75
76
|
|
|
76
77
|
dispatch({
|
|
@@ -83,8 +84,8 @@ export default {
|
|
|
83
84
|
});
|
|
84
85
|
} else {
|
|
85
86
|
try {
|
|
86
|
-
debugger
|
|
87
87
|
const data = JSON.parse(body);
|
|
88
|
+
// debugger
|
|
88
89
|
console.log(data)
|
|
89
90
|
if (type === "EsriFeatureService") {
|
|
90
91
|
if (legendOverride === true) {
|
|
@@ -207,6 +208,9 @@ export default {
|
|
|
207
208
|
};
|
|
208
209
|
legendLayers[uid] = [];
|
|
209
210
|
//TODO Logic below is needs to include other Esri styles.
|
|
211
|
+
console.log(drawingInfo.renderer);
|
|
212
|
+
console.log(drawingInfo.renderer.symbol)
|
|
213
|
+
// debugger
|
|
210
214
|
switch (data.geometryType) {
|
|
211
215
|
case "esriGeometryPolygon":
|
|
212
216
|
if (
|
|
@@ -259,7 +263,66 @@ export default {
|
|
|
259
263
|
loading: false,
|
|
260
264
|
},
|
|
261
265
|
});
|
|
262
|
-
}
|
|
266
|
+
}
|
|
267
|
+
//__________________________________________________________________________________________________________________________________
|
|
268
|
+
else if(
|
|
269
|
+
drawingInfo.renderer.symbol &&
|
|
270
|
+
drawingInfo.renderer.symbol.type === "esriSFS" &&
|
|
271
|
+
drawingInfo.renderer.symbol.style === "esriSFSBackwardDiagonal"
|
|
272
|
+
) {
|
|
273
|
+
// debugger
|
|
274
|
+
let img = new Image();
|
|
275
|
+
const outlineColor = drawingInfo.renderer.symbol.outline.color;
|
|
276
|
+
const fillColor = drawingInfo.renderer.symbol.color;
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
let canvas = document.createElement("canvas");
|
|
280
|
+
let ctx = canvas.getContext("2d");
|
|
281
|
+
|
|
282
|
+
canvas.width = 20;
|
|
283
|
+
canvas.height = 20;
|
|
284
|
+
|
|
285
|
+
//store width & height for larger canvas calculation
|
|
286
|
+
legendCanvases[uid].widths.push(canvas.width);
|
|
287
|
+
legendCanvases[uid].heights.push(canvas.height);
|
|
288
|
+
|
|
289
|
+
// // Draw polygon
|
|
290
|
+
ctx.beginPath();
|
|
291
|
+
ctx.moveTo(0, 10);
|
|
292
|
+
ctx.lineTo(10, 0);
|
|
293
|
+
ctx.moveTo(0, 20);
|
|
294
|
+
ctx.lineTo(20, 0);
|
|
295
|
+
ctx.moveTo(10, 20);
|
|
296
|
+
ctx.lineTo(20, 10);
|
|
297
|
+
ctx.lineWidth = "2";
|
|
298
|
+
ctx.strokeStyle = `rgba(${outlineColor.join()})`;
|
|
299
|
+
ctx.rect(0, 0, 20, 20);
|
|
300
|
+
ctx.stroke();
|
|
301
|
+
|
|
302
|
+
img.src = canvas.toDataURL(); //set src using data URI from canvas
|
|
303
|
+
img.alt = `Style for ${displayName}`;
|
|
304
|
+
img.crossOrigin = "anonymous";
|
|
305
|
+
|
|
306
|
+
legendCanvases[uid].canvas.push(canvas);
|
|
307
|
+
dispatch({
|
|
308
|
+
type: "LEGEND_CANVAS_ADDED",
|
|
309
|
+
payload: {
|
|
310
|
+
legendCanvases: legendCanvases,
|
|
311
|
+
loading: false,
|
|
312
|
+
},
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
legendLayers[uid].push(img);
|
|
316
|
+
dispatch({
|
|
317
|
+
type: "LEGEND_LAYERS_UPDATED",
|
|
318
|
+
payload: {
|
|
319
|
+
legendLayers: legendLayers,
|
|
320
|
+
loading: false,
|
|
321
|
+
},
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
//____________________________________________________________________________________________________________________________________
|
|
325
|
+
else if (
|
|
263
326
|
drawingInfo.renderer.type === "uniqueValue" &&
|
|
264
327
|
drawingInfo.renderer.uniqueValueInfos
|
|
265
328
|
) {
|
|
@@ -424,7 +487,7 @@ export default {
|
|
|
424
487
|
}
|
|
425
488
|
break;
|
|
426
489
|
case "esriGeometryPoint":
|
|
427
|
-
if (drawingInfo.renderer.symbol.type === "esriPMS") {
|
|
490
|
+
if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriPMS") {
|
|
428
491
|
let img = new Image();
|
|
429
492
|
img.src = `data:image/png;base64,${data.drawingInfo.renderer.symbol.imageData}`;
|
|
430
493
|
img.addEventListener(
|
|
@@ -468,7 +531,7 @@ export default {
|
|
|
468
531
|
legendLayers: legendLayers,
|
|
469
532
|
},
|
|
470
533
|
});
|
|
471
|
-
} else if (drawingInfo.renderer.symbol.type === "esriSMS") {
|
|
534
|
+
} else if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriSMS") {
|
|
472
535
|
let img = new Image();
|
|
473
536
|
const outlineColor = drawingInfo.renderer.symbol.outline.color;
|
|
474
537
|
const outlineWidth = drawingInfo.renderer.symbol.outline.width;
|
|
@@ -514,7 +577,114 @@ export default {
|
|
|
514
577
|
loading: false,
|
|
515
578
|
},
|
|
516
579
|
});
|
|
517
|
-
}
|
|
580
|
+
}
|
|
581
|
+
//___________________________________________________________________________________________________________________________________
|
|
582
|
+
else if (drawingInfo.renderer.uniqueValueInfos){
|
|
583
|
+
// let canvas = document.createElement("canvas");
|
|
584
|
+
// let ctx = canvas.getContext("2d");
|
|
585
|
+
let result = []
|
|
586
|
+
let images = []
|
|
587
|
+
drawingInfo.renderer.uniqueValueInfos.forEach((val) => {
|
|
588
|
+
|
|
589
|
+
let label = val.label
|
|
590
|
+
let wkCanvas;
|
|
591
|
+
let img = new Image();
|
|
592
|
+
img.src = `data:image/png;base64,${val.symbol.imageData}`;
|
|
593
|
+
|
|
594
|
+
// img.addEventListener(
|
|
595
|
+
// "load",
|
|
596
|
+
// function () {
|
|
597
|
+
let canvas = document.createElement("canvas");
|
|
598
|
+
let ctx = canvas.getContext("2d")
|
|
599
|
+
|
|
600
|
+
const labelWidth = Number(ctx.measureText(label).width);
|
|
601
|
+
|
|
602
|
+
//set canvas width & height
|
|
603
|
+
canvas.width = Number(val.symbol.width) + labelWidth + 4;
|
|
604
|
+
canvas.height = val.symbol.height;
|
|
605
|
+
|
|
606
|
+
//store width & height for larger canvas calculation
|
|
607
|
+
// legendCanvases[uid].widths.push(canvas.width);
|
|
608
|
+
// legendCanvases[uid].heights.push(canvas.height);
|
|
609
|
+
|
|
610
|
+
//set background
|
|
611
|
+
ctx.fillStyle = "white";
|
|
612
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
613
|
+
// // ctx.putImageData(val.symbol.imageData, 0,0)
|
|
614
|
+
|
|
615
|
+
ctx.drawImage(img, 0, 0); //add image to canvas
|
|
616
|
+
|
|
617
|
+
// //add label to the right of image
|
|
618
|
+
// ctx.font = "10px Arial";
|
|
619
|
+
// ctx.fillStyle = "black";
|
|
620
|
+
|
|
621
|
+
// ctx.fillText(label, canvas.width + 2, canvas.height / 2);
|
|
622
|
+
|
|
623
|
+
// legendCanvases[uid].canvas.push(canvas);
|
|
624
|
+
|
|
625
|
+
// dispatch({
|
|
626
|
+
// type: "LEGEND_CANVAS_ADDED",
|
|
627
|
+
// payload: {
|
|
628
|
+
// legendCanvases: legendCanvases,
|
|
629
|
+
// loading: false,
|
|
630
|
+
// },
|
|
631
|
+
// });
|
|
632
|
+
// result.push(canvas)
|
|
633
|
+
// },
|
|
634
|
+
// false
|
|
635
|
+
// );
|
|
636
|
+
// img.src = `data:${val.symbol.url};base64,${val.symbol.imageData}`
|
|
637
|
+
// img.src = canvas.toDataURL()
|
|
638
|
+
|
|
639
|
+
img.alt = `Style for ${label}`;
|
|
640
|
+
img.crossOrigin = "anonymous";
|
|
641
|
+
img.title = label;
|
|
642
|
+
// legendLayers[uid] = [img]; //TODO: Update to possibly push multiple images into array
|
|
643
|
+
// images.push(img)
|
|
644
|
+
|
|
645
|
+
// dispatch({
|
|
646
|
+
// type: "LEGEND_LAYERS_UPDATED",
|
|
647
|
+
// payload: {
|
|
648
|
+
// legendLayers: legendLayers,
|
|
649
|
+
// },
|
|
650
|
+
// });
|
|
651
|
+
result.push({
|
|
652
|
+
canvas: canvas,
|
|
653
|
+
image: img,
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
});
|
|
657
|
+
result.forEach((item) => {
|
|
658
|
+
|
|
659
|
+
item.image.alt = `Style for ${lyr.displayName}`;
|
|
660
|
+
|
|
661
|
+
legendCanvases[lyr.uid].widths.push(item.canvas.width);
|
|
662
|
+
|
|
663
|
+
legendCanvases[lyr.uid].heights.push(item.canvas.height);
|
|
664
|
+
|
|
665
|
+
legendCanvases[lyr.uid].canvas.push(item.canvas);
|
|
666
|
+
|
|
667
|
+
legendLayers[lyr.uid].push(item.image);
|
|
668
|
+
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
dispatch({
|
|
672
|
+
|
|
673
|
+
type: "LEGEND_CANVAS_ADDED",
|
|
674
|
+
|
|
675
|
+
payload: {
|
|
676
|
+
|
|
677
|
+
legendCanvases: legendCanvases,
|
|
678
|
+
|
|
679
|
+
loading: false,
|
|
680
|
+
|
|
681
|
+
},
|
|
682
|
+
|
|
683
|
+
});
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
else {
|
|
687
|
+
|
|
518
688
|
legendLayers[uid] = ["Legend not available!"];
|
|
519
689
|
dispatch({
|
|
520
690
|
type: "LEGEND_LAYERS_UPDATE_ERROR",
|