@corpsmap/corpsmap 3.2.34 → 3.2.36
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 +237 -54
- package/lib/prod.js +237 -54
- package/package.json +1 -1
- package/src/core-plugins/legend/bundle.js +217 -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.36";
|
|
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,66 @@ var bundle$8 = {
|
|
|
159606
159609
|
loading: false
|
|
159607
159610
|
}
|
|
159608
159611
|
});
|
|
159609
|
-
} else if (drawingInfo.renderer.type === "
|
|
159612
|
+
} else if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriSFS" && drawingInfo.renderer.symbol.style === "esriSFSBackwardDiagonal") {
|
|
159613
|
+
// debugger
|
|
159614
|
+
var _img = new Image();
|
|
159615
|
+
|
|
159616
|
+
var _outlineColor = drawingInfo.renderer.symbol.outline.color;
|
|
159617
|
+
var _fillColor = drawingInfo.renderer.symbol.color;
|
|
159618
|
+
|
|
159619
|
+
var _canvas = document.createElement("canvas");
|
|
159620
|
+
|
|
159621
|
+
var _ctx = _canvas.getContext("2d");
|
|
159622
|
+
|
|
159623
|
+
_canvas.width = 20;
|
|
159624
|
+
_canvas.height = 20; //store width & height for larger canvas calculation
|
|
159625
|
+
|
|
159626
|
+
legendCanvases[uid].widths.push(_canvas.width);
|
|
159627
|
+
legendCanvases[uid].heights.push(_canvas.height); // // Draw polygon
|
|
159628
|
+
|
|
159629
|
+
_ctx.beginPath();
|
|
159630
|
+
|
|
159631
|
+
_ctx.moveTo(0, 10);
|
|
159632
|
+
|
|
159633
|
+
_ctx.lineTo(10, 0);
|
|
159634
|
+
|
|
159635
|
+
_ctx.moveTo(0, 20);
|
|
159636
|
+
|
|
159637
|
+
_ctx.lineTo(20, 0);
|
|
159638
|
+
|
|
159639
|
+
_ctx.moveTo(10, 20);
|
|
159640
|
+
|
|
159641
|
+
_ctx.lineTo(20, 10);
|
|
159642
|
+
|
|
159643
|
+
_ctx.lineWidth = "2";
|
|
159644
|
+
_ctx.strokeStyle = "rgba(".concat(_outlineColor.join(), ")");
|
|
159645
|
+
|
|
159646
|
+
_ctx.rect(0, 0, 20, 20);
|
|
159647
|
+
|
|
159648
|
+
_ctx.stroke();
|
|
159649
|
+
|
|
159650
|
+
_img.src = _canvas.toDataURL(); //set src using data URI from canvas
|
|
159651
|
+
|
|
159652
|
+
_img.alt = "Style for ".concat(displayName);
|
|
159653
|
+
_img.crossOrigin = "anonymous";
|
|
159654
|
+
legendCanvases[uid].canvas.push(_canvas);
|
|
159655
|
+
dispatch({
|
|
159656
|
+
type: "LEGEND_CANVAS_ADDED",
|
|
159657
|
+
payload: {
|
|
159658
|
+
legendCanvases: legendCanvases,
|
|
159659
|
+
loading: false
|
|
159660
|
+
}
|
|
159661
|
+
});
|
|
159662
|
+
legendLayers[uid].push(_img);
|
|
159663
|
+
dispatch({
|
|
159664
|
+
type: "LEGEND_LAYERS_UPDATED",
|
|
159665
|
+
payload: {
|
|
159666
|
+
legendLayers: legendLayers,
|
|
159667
|
+
loading: false
|
|
159668
|
+
}
|
|
159669
|
+
});
|
|
159670
|
+
} //____________________________________________________________________________________________________________________________________
|
|
159671
|
+
else if (drawingInfo.renderer.type === "uniqueValue" && drawingInfo.renderer.uniqueValueInfos) {
|
|
159610
159672
|
drawingInfo.renderer.uniqueValueInfos.forEach(function (val) {
|
|
159611
159673
|
var img = new Image();
|
|
159612
159674
|
var outlineColor = val.symbol.outline.color;
|
|
@@ -159659,35 +159721,35 @@ var bundle$8 = {
|
|
|
159659
159721
|
|
|
159660
159722
|
case "esriGeometryPolyline":
|
|
159661
159723
|
if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriSLS" && drawingInfo.renderer.symbol.style === "esriSLSSolid") {
|
|
159662
|
-
var
|
|
159724
|
+
var _img2 = new Image();
|
|
159663
159725
|
|
|
159664
|
-
var
|
|
159726
|
+
var _canvas2 = document.createElement("canvas");
|
|
159665
159727
|
|
|
159666
|
-
var
|
|
159728
|
+
var _ctx2 = _canvas2.getContext("2d");
|
|
159667
159729
|
|
|
159668
159730
|
var lineColor = drawingInfo.renderer.symbol.color;
|
|
159669
|
-
|
|
159670
|
-
|
|
159731
|
+
_canvas2.width = 20;
|
|
159732
|
+
_canvas2.height = 20; //store width & height for larger canvas calculation
|
|
159671
159733
|
|
|
159672
|
-
legendCanvases[uid].widths.push(
|
|
159673
|
-
legendCanvases[uid].heights.push(
|
|
159734
|
+
legendCanvases[uid].widths.push(_canvas2.width);
|
|
159735
|
+
legendCanvases[uid].heights.push(_canvas2.height); // Draw line
|
|
159674
159736
|
|
|
159675
|
-
|
|
159737
|
+
_ctx2.beginPath();
|
|
159676
159738
|
|
|
159677
|
-
|
|
159739
|
+
_ctx2.strokeStyle = "rgba(".concat(lineColor.join(), ")");
|
|
159678
159740
|
|
|
159679
|
-
|
|
159741
|
+
_ctx2.moveTo(0, 0);
|
|
159680
159742
|
|
|
159681
|
-
|
|
159743
|
+
_ctx2.lineTo(20, 20);
|
|
159682
159744
|
|
|
159683
|
-
|
|
159745
|
+
_ctx2.stroke(); //set img attributes
|
|
159684
159746
|
|
|
159685
159747
|
|
|
159686
|
-
|
|
159748
|
+
_img2.src = _canvas2.toDataURL(); //set src using data URI from canvas
|
|
159687
159749
|
|
|
159688
|
-
|
|
159689
|
-
|
|
159690
|
-
legendCanvases[uid].canvas.push(
|
|
159750
|
+
_img2.alt = "Style for ".concat(displayName);
|
|
159751
|
+
_img2.crossOrigin = "anonymous";
|
|
159752
|
+
legendCanvases[uid].canvas.push(_canvas2);
|
|
159691
159753
|
dispatch({
|
|
159692
159754
|
type: "LEGEND_CANVAS_ADDED",
|
|
159693
159755
|
payload: {
|
|
@@ -159695,7 +159757,7 @@ var bundle$8 = {
|
|
|
159695
159757
|
loading: false
|
|
159696
159758
|
}
|
|
159697
159759
|
});
|
|
159698
|
-
legendLayers[uid].push(
|
|
159760
|
+
legendLayers[uid].push(_img2);
|
|
159699
159761
|
dispatch({
|
|
159700
159762
|
type: "LEGEND_LAYERS_UPDATED",
|
|
159701
159763
|
payload: {
|
|
@@ -159752,12 +159814,12 @@ var bundle$8 = {
|
|
|
159752
159814
|
break;
|
|
159753
159815
|
|
|
159754
159816
|
case "esriGeometryPoint":
|
|
159755
|
-
if (drawingInfo.renderer.symbol.type === "esriPMS") {
|
|
159756
|
-
var
|
|
159817
|
+
if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriPMS") {
|
|
159818
|
+
var _img3 = new Image();
|
|
159757
159819
|
|
|
159758
|
-
|
|
159820
|
+
_img3.src = "data:image/png;base64,".concat(data.drawingInfo.renderer.symbol.imageData);
|
|
159759
159821
|
|
|
159760
|
-
|
|
159822
|
+
_img3.addEventListener("load", function () {
|
|
159761
159823
|
var canvas = document.createElement("canvas");
|
|
159762
159824
|
var ctx = canvas.getContext("2d");
|
|
159763
159825
|
canvas.width = drawingInfo.renderer.symbol.width;
|
|
@@ -159768,7 +159830,7 @@ var bundle$8 = {
|
|
|
159768
159830
|
|
|
159769
159831
|
ctx.fillStyle = "white";
|
|
159770
159832
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
159771
|
-
ctx.drawImage(
|
|
159833
|
+
ctx.drawImage(_img3, 0, 0); //add image to canvas
|
|
159772
159834
|
|
|
159773
159835
|
legendCanvases[uid].canvas.push(canvas);
|
|
159774
159836
|
dispatch({
|
|
@@ -159780,9 +159842,9 @@ var bundle$8 = {
|
|
|
159780
159842
|
});
|
|
159781
159843
|
}, false);
|
|
159782
159844
|
|
|
159783
|
-
|
|
159784
|
-
|
|
159785
|
-
legendLayers[uid] = [
|
|
159845
|
+
_img3.alt = "Style for ".concat(displayName);
|
|
159846
|
+
_img3.crossOrigin = "anonymous";
|
|
159847
|
+
legendLayers[uid] = [_img3]; //TODO: Update to possibly push multiple images into array
|
|
159786
159848
|
|
|
159787
159849
|
dispatch({
|
|
159788
159850
|
type: "LEGEND_LAYERS_UPDATED",
|
|
@@ -159790,41 +159852,41 @@ var bundle$8 = {
|
|
|
159790
159852
|
legendLayers: legendLayers
|
|
159791
159853
|
}
|
|
159792
159854
|
});
|
|
159793
|
-
} else if (drawingInfo.renderer.symbol.type === "esriSMS") {
|
|
159794
|
-
var
|
|
159855
|
+
} else if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriSMS") {
|
|
159856
|
+
var _img4 = new Image();
|
|
159795
159857
|
|
|
159796
|
-
var
|
|
159858
|
+
var _outlineColor2 = drawingInfo.renderer.symbol.outline.color;
|
|
159797
159859
|
var outlineWidth = drawingInfo.renderer.symbol.outline.width;
|
|
159798
|
-
var
|
|
159860
|
+
var _fillColor2 = drawingInfo.renderer.symbol.color;
|
|
159799
159861
|
var size = drawingInfo.renderer.symbol.size;
|
|
159800
159862
|
|
|
159801
|
-
var
|
|
159863
|
+
var _canvas3 = document.createElement("canvas");
|
|
159802
159864
|
|
|
159803
|
-
var
|
|
159865
|
+
var _ctx3 = _canvas3.getContext("2d");
|
|
159804
159866
|
|
|
159805
|
-
|
|
159806
|
-
|
|
159807
|
-
legendCanvases[uid].widths.push(
|
|
159808
|
-
legendCanvases[uid].heights.push(
|
|
159867
|
+
_canvas3.width = 20;
|
|
159868
|
+
_canvas3.height = 20;
|
|
159869
|
+
legendCanvases[uid].widths.push(_canvas3.width);
|
|
159870
|
+
legendCanvases[uid].heights.push(_canvas3.height); // circle
|
|
159809
159871
|
|
|
159810
|
-
|
|
159872
|
+
_ctx3.beginPath();
|
|
159811
159873
|
|
|
159812
|
-
|
|
159813
|
-
|
|
159874
|
+
_ctx3.strokeStyle = "rgba(".concat(_outlineColor2.join(), ")");
|
|
159875
|
+
_ctx3.lineWidth = outlineWidth;
|
|
159814
159876
|
|
|
159815
|
-
|
|
159877
|
+
_ctx3.arc(size, size, size / 1.5, 0, Math.PI * 2);
|
|
159816
159878
|
|
|
159817
|
-
|
|
159879
|
+
_ctx3.fillStyle = "rgba(".concat(_fillColor2.join(), ")");
|
|
159818
159880
|
|
|
159819
|
-
|
|
159881
|
+
_ctx3.fill();
|
|
159820
159882
|
|
|
159821
|
-
|
|
159883
|
+
_ctx3.stroke();
|
|
159822
159884
|
|
|
159823
|
-
|
|
159885
|
+
_img4.src = _canvas3.toDataURL(); //set src using data URI from canvas
|
|
159824
159886
|
|
|
159825
|
-
|
|
159826
|
-
|
|
159827
|
-
legendCanvases[uid].canvas.push(
|
|
159887
|
+
_img4.alt = "Style for ".concat(displayName);
|
|
159888
|
+
_img4.crossOrigin = "anonymous";
|
|
159889
|
+
legendCanvases[uid].canvas.push(_canvas3);
|
|
159828
159890
|
dispatch({
|
|
159829
159891
|
type: "LEGEND_CANVAS_ADDED",
|
|
159830
159892
|
payload: {
|
|
@@ -159832,7 +159894,7 @@ var bundle$8 = {
|
|
|
159832
159894
|
loading: false
|
|
159833
159895
|
}
|
|
159834
159896
|
});
|
|
159835
|
-
legendLayers[uid].push(
|
|
159897
|
+
legendLayers[uid].push(_img4);
|
|
159836
159898
|
dispatch({
|
|
159837
159899
|
type: "LEGEND_LAYERS_UPDATED",
|
|
159838
159900
|
payload: {
|
|
@@ -159840,6 +159902,127 @@ var bundle$8 = {
|
|
|
159840
159902
|
loading: false
|
|
159841
159903
|
}
|
|
159842
159904
|
});
|
|
159905
|
+
} //___________________________________________________________________________________________________________________________________
|
|
159906
|
+
else if (drawingInfo.renderer.uniqueValueInfos) {
|
|
159907
|
+
// let canvas = document.createElement("canvas");
|
|
159908
|
+
// let ctx = canvas.getContext("2d");
|
|
159909
|
+
var result = [];
|
|
159910
|
+
drawingInfo.renderer.uniqueValueInfos.forEach(function (val) {
|
|
159911
|
+
var label = val.label;
|
|
159912
|
+
var img = new Image();
|
|
159913
|
+
img.src = "data:image/png;base64,".concat(val.symbol.imageData); // img.addEventListener(
|
|
159914
|
+
// "load",
|
|
159915
|
+
// function () {
|
|
159916
|
+
|
|
159917
|
+
var canvas = document.createElement("canvas");
|
|
159918
|
+
var ctx = canvas.getContext("2d");
|
|
159919
|
+
var labelWidth = Number(ctx.measureText(label).width); //set canvas width & height
|
|
159920
|
+
|
|
159921
|
+
canvas.width = Number(val.symbol.width) + labelWidth + 4;
|
|
159922
|
+
canvas.height = val.symbol.height; //store width & height for larger canvas calculation
|
|
159923
|
+
// legendCanvases[uid].widths.push(canvas.width);
|
|
159924
|
+
// legendCanvases[uid].heights.push(canvas.height);
|
|
159925
|
+
//set background
|
|
159926
|
+
|
|
159927
|
+
ctx.fillStyle = "white";
|
|
159928
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height); // // ctx.putImageData(val.symbol.imageData, 0,0)
|
|
159929
|
+
|
|
159930
|
+
ctx.drawImage(img, 0, 0); //add image to canvas
|
|
159931
|
+
// //add label to the right of image
|
|
159932
|
+
// ctx.font = "10px Arial";
|
|
159933
|
+
// ctx.fillStyle = "black";
|
|
159934
|
+
// ctx.fillText(label, canvas.width + 2, canvas.height / 2);
|
|
159935
|
+
// legendCanvases[uid].canvas.push(canvas);
|
|
159936
|
+
// dispatch({
|
|
159937
|
+
// type: "LEGEND_CANVAS_ADDED",
|
|
159938
|
+
// payload: {
|
|
159939
|
+
// legendCanvases: legendCanvases,
|
|
159940
|
+
// loading: false,
|
|
159941
|
+
// },
|
|
159942
|
+
// });
|
|
159943
|
+
// result.push(canvas)
|
|
159944
|
+
// },
|
|
159945
|
+
// false
|
|
159946
|
+
// );
|
|
159947
|
+
// img.src = `data:${val.symbol.url};base64,${val.symbol.imageData}`
|
|
159948
|
+
// img.src = canvas.toDataURL()
|
|
159949
|
+
|
|
159950
|
+
img.alt = "Style for ".concat(label);
|
|
159951
|
+
img.crossOrigin = "anonymous";
|
|
159952
|
+
img.title = label; // legendLayers[uid] = [img]; //TODO: Update to possibly push multiple images into array
|
|
159953
|
+
// images.push(img)
|
|
159954
|
+
// dispatch({
|
|
159955
|
+
// type: "LEGEND_LAYERS_UPDATED",
|
|
159956
|
+
// payload: {
|
|
159957
|
+
// legendLayers: legendLayers,
|
|
159958
|
+
// },
|
|
159959
|
+
// });
|
|
159960
|
+
|
|
159961
|
+
result.push({
|
|
159962
|
+
canvas: canvas,
|
|
159963
|
+
image: img
|
|
159964
|
+
});
|
|
159965
|
+
});
|
|
159966
|
+
result.forEach(function (item) {
|
|
159967
|
+
item.image.alt = "Style for ".concat(lyr.displayName);
|
|
159968
|
+
legendCanvases[lyr.uid].widths.push(item.canvas.width);
|
|
159969
|
+
legendCanvases[lyr.uid].heights.push(item.canvas.height);
|
|
159970
|
+
legendCanvases[lyr.uid].canvas.push(item.canvas);
|
|
159971
|
+
legendLayers[lyr.uid].push(item.image);
|
|
159972
|
+
dispatch({
|
|
159973
|
+
type: "LEGEND_CANVAS_ADDED",
|
|
159974
|
+
payload: {
|
|
159975
|
+
legendCanvases: legendCanvases,
|
|
159976
|
+
loading: false
|
|
159977
|
+
}
|
|
159978
|
+
});
|
|
159979
|
+
});
|
|
159980
|
+
} else if (drawingInfo.renderer.classBreakInfos) {
|
|
159981
|
+
drawingInfo.renderer.classBreakInfos.forEach(function (val) {
|
|
159982
|
+
var img = new Image();
|
|
159983
|
+
var outlineColor = val.symbol.outline.color;
|
|
159984
|
+
var outlineWidth = val.symbol.outline.width;
|
|
159985
|
+
var fillColor = val.symbol.color;
|
|
159986
|
+
var size = val.symbol.size;
|
|
159987
|
+
var canvas = document.createElement("canvas");
|
|
159988
|
+
var ctx = canvas.getContext("2d");
|
|
159989
|
+
canvas.width = 20 * 2.5;
|
|
159990
|
+
canvas.height = 20;
|
|
159991
|
+
legendCanvases[uid].widths.push(canvas.width);
|
|
159992
|
+
legendCanvases[uid].heights.push(canvas.height); //text
|
|
159993
|
+
|
|
159994
|
+
ctx.font = "11px Arial";
|
|
159995
|
+
ctx.fillText(val.label, size * 3, size * 2, 30); // circle
|
|
159996
|
+
|
|
159997
|
+
ctx.beginPath();
|
|
159998
|
+
ctx.strokeStyle = "rgba(".concat(outlineColor.join(), ")");
|
|
159999
|
+
ctx.lineWidth = outlineWidth;
|
|
160000
|
+
ctx.arc(size, size * 1.5, size / 1.5, 0, Math.PI * 2);
|
|
160001
|
+
ctx.fillStyle = "rgba(".concat(fillColor.join(), ")");
|
|
160002
|
+
ctx.fill();
|
|
160003
|
+
ctx.stroke();
|
|
160004
|
+
img.src = canvas.toDataURL(); //set src using data URI from canvas
|
|
160005
|
+
|
|
160006
|
+
img.alt = "Style for ".concat(displayName);
|
|
160007
|
+
img.crossOrigin = "anonymous";
|
|
160008
|
+
debugger;
|
|
160009
|
+
legendCanvases[uid].canvas.push(canvas);
|
|
160010
|
+
dispatch({
|
|
160011
|
+
type: "LEGEND_CANVAS_ADDED",
|
|
160012
|
+
payload: {
|
|
160013
|
+
legendCanvases: legendCanvases,
|
|
160014
|
+
loading: false
|
|
160015
|
+
}
|
|
160016
|
+
});
|
|
160017
|
+
legendLayers[uid].push(img);
|
|
160018
|
+
dispatch({
|
|
160019
|
+
type: "LEGEND_LAYERS_UPDATED",
|
|
160020
|
+
payload: {
|
|
160021
|
+
legendLayers: legendLayers,
|
|
160022
|
+
loading: false
|
|
160023
|
+
}
|
|
160024
|
+
});
|
|
160025
|
+
});
|
|
159843
160026
|
} else {
|
|
159844
160027
|
legendLayers[uid] = ["Legend not available!"];
|
|
159845
160028
|
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.36";
|
|
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,66 @@ var bundle$8 = {
|
|
|
159520
159523
|
loading: false
|
|
159521
159524
|
}
|
|
159522
159525
|
});
|
|
159523
|
-
} else if (drawingInfo.renderer.type === "
|
|
159526
|
+
} else if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriSFS" && drawingInfo.renderer.symbol.style === "esriSFSBackwardDiagonal") {
|
|
159527
|
+
// debugger
|
|
159528
|
+
var _img = new Image();
|
|
159529
|
+
|
|
159530
|
+
var _outlineColor = drawingInfo.renderer.symbol.outline.color;
|
|
159531
|
+
var _fillColor = drawingInfo.renderer.symbol.color;
|
|
159532
|
+
|
|
159533
|
+
var _canvas = document.createElement("canvas");
|
|
159534
|
+
|
|
159535
|
+
var _ctx = _canvas.getContext("2d");
|
|
159536
|
+
|
|
159537
|
+
_canvas.width = 20;
|
|
159538
|
+
_canvas.height = 20; //store width & height for larger canvas calculation
|
|
159539
|
+
|
|
159540
|
+
legendCanvases[uid].widths.push(_canvas.width);
|
|
159541
|
+
legendCanvases[uid].heights.push(_canvas.height); // // Draw polygon
|
|
159542
|
+
|
|
159543
|
+
_ctx.beginPath();
|
|
159544
|
+
|
|
159545
|
+
_ctx.moveTo(0, 10);
|
|
159546
|
+
|
|
159547
|
+
_ctx.lineTo(10, 0);
|
|
159548
|
+
|
|
159549
|
+
_ctx.moveTo(0, 20);
|
|
159550
|
+
|
|
159551
|
+
_ctx.lineTo(20, 0);
|
|
159552
|
+
|
|
159553
|
+
_ctx.moveTo(10, 20);
|
|
159554
|
+
|
|
159555
|
+
_ctx.lineTo(20, 10);
|
|
159556
|
+
|
|
159557
|
+
_ctx.lineWidth = "2";
|
|
159558
|
+
_ctx.strokeStyle = "rgba(".concat(_outlineColor.join(), ")");
|
|
159559
|
+
|
|
159560
|
+
_ctx.rect(0, 0, 20, 20);
|
|
159561
|
+
|
|
159562
|
+
_ctx.stroke();
|
|
159563
|
+
|
|
159564
|
+
_img.src = _canvas.toDataURL(); //set src using data URI from canvas
|
|
159565
|
+
|
|
159566
|
+
_img.alt = "Style for ".concat(displayName);
|
|
159567
|
+
_img.crossOrigin = "anonymous";
|
|
159568
|
+
legendCanvases[uid].canvas.push(_canvas);
|
|
159569
|
+
dispatch({
|
|
159570
|
+
type: "LEGEND_CANVAS_ADDED",
|
|
159571
|
+
payload: {
|
|
159572
|
+
legendCanvases: legendCanvases,
|
|
159573
|
+
loading: false
|
|
159574
|
+
}
|
|
159575
|
+
});
|
|
159576
|
+
legendLayers[uid].push(_img);
|
|
159577
|
+
dispatch({
|
|
159578
|
+
type: "LEGEND_LAYERS_UPDATED",
|
|
159579
|
+
payload: {
|
|
159580
|
+
legendLayers: legendLayers,
|
|
159581
|
+
loading: false
|
|
159582
|
+
}
|
|
159583
|
+
});
|
|
159584
|
+
} //____________________________________________________________________________________________________________________________________
|
|
159585
|
+
else if (drawingInfo.renderer.type === "uniqueValue" && drawingInfo.renderer.uniqueValueInfos) {
|
|
159524
159586
|
drawingInfo.renderer.uniqueValueInfos.forEach(function (val) {
|
|
159525
159587
|
var img = new Image();
|
|
159526
159588
|
var outlineColor = val.symbol.outline.color;
|
|
@@ -159573,35 +159635,35 @@ var bundle$8 = {
|
|
|
159573
159635
|
|
|
159574
159636
|
case "esriGeometryPolyline":
|
|
159575
159637
|
if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriSLS" && drawingInfo.renderer.symbol.style === "esriSLSSolid") {
|
|
159576
|
-
var
|
|
159638
|
+
var _img2 = new Image();
|
|
159577
159639
|
|
|
159578
|
-
var
|
|
159640
|
+
var _canvas2 = document.createElement("canvas");
|
|
159579
159641
|
|
|
159580
|
-
var
|
|
159642
|
+
var _ctx2 = _canvas2.getContext("2d");
|
|
159581
159643
|
|
|
159582
159644
|
var lineColor = drawingInfo.renderer.symbol.color;
|
|
159583
|
-
|
|
159584
|
-
|
|
159645
|
+
_canvas2.width = 20;
|
|
159646
|
+
_canvas2.height = 20; //store width & height for larger canvas calculation
|
|
159585
159647
|
|
|
159586
|
-
legendCanvases[uid].widths.push(
|
|
159587
|
-
legendCanvases[uid].heights.push(
|
|
159648
|
+
legendCanvases[uid].widths.push(_canvas2.width);
|
|
159649
|
+
legendCanvases[uid].heights.push(_canvas2.height); // Draw line
|
|
159588
159650
|
|
|
159589
|
-
|
|
159651
|
+
_ctx2.beginPath();
|
|
159590
159652
|
|
|
159591
|
-
|
|
159653
|
+
_ctx2.strokeStyle = "rgba(".concat(lineColor.join(), ")");
|
|
159592
159654
|
|
|
159593
|
-
|
|
159655
|
+
_ctx2.moveTo(0, 0);
|
|
159594
159656
|
|
|
159595
|
-
|
|
159657
|
+
_ctx2.lineTo(20, 20);
|
|
159596
159658
|
|
|
159597
|
-
|
|
159659
|
+
_ctx2.stroke(); //set img attributes
|
|
159598
159660
|
|
|
159599
159661
|
|
|
159600
|
-
|
|
159662
|
+
_img2.src = _canvas2.toDataURL(); //set src using data URI from canvas
|
|
159601
159663
|
|
|
159602
|
-
|
|
159603
|
-
|
|
159604
|
-
legendCanvases[uid].canvas.push(
|
|
159664
|
+
_img2.alt = "Style for ".concat(displayName);
|
|
159665
|
+
_img2.crossOrigin = "anonymous";
|
|
159666
|
+
legendCanvases[uid].canvas.push(_canvas2);
|
|
159605
159667
|
dispatch({
|
|
159606
159668
|
type: "LEGEND_CANVAS_ADDED",
|
|
159607
159669
|
payload: {
|
|
@@ -159609,7 +159671,7 @@ var bundle$8 = {
|
|
|
159609
159671
|
loading: false
|
|
159610
159672
|
}
|
|
159611
159673
|
});
|
|
159612
|
-
legendLayers[uid].push(
|
|
159674
|
+
legendLayers[uid].push(_img2);
|
|
159613
159675
|
dispatch({
|
|
159614
159676
|
type: "LEGEND_LAYERS_UPDATED",
|
|
159615
159677
|
payload: {
|
|
@@ -159666,12 +159728,12 @@ var bundle$8 = {
|
|
|
159666
159728
|
break;
|
|
159667
159729
|
|
|
159668
159730
|
case "esriGeometryPoint":
|
|
159669
|
-
if (drawingInfo.renderer.symbol.type === "esriPMS") {
|
|
159670
|
-
var
|
|
159731
|
+
if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriPMS") {
|
|
159732
|
+
var _img3 = new Image();
|
|
159671
159733
|
|
|
159672
|
-
|
|
159734
|
+
_img3.src = "data:image/png;base64,".concat(data.drawingInfo.renderer.symbol.imageData);
|
|
159673
159735
|
|
|
159674
|
-
|
|
159736
|
+
_img3.addEventListener("load", function () {
|
|
159675
159737
|
var canvas = document.createElement("canvas");
|
|
159676
159738
|
var ctx = canvas.getContext("2d");
|
|
159677
159739
|
canvas.width = drawingInfo.renderer.symbol.width;
|
|
@@ -159682,7 +159744,7 @@ var bundle$8 = {
|
|
|
159682
159744
|
|
|
159683
159745
|
ctx.fillStyle = "white";
|
|
159684
159746
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
159685
|
-
ctx.drawImage(
|
|
159747
|
+
ctx.drawImage(_img3, 0, 0); //add image to canvas
|
|
159686
159748
|
|
|
159687
159749
|
legendCanvases[uid].canvas.push(canvas);
|
|
159688
159750
|
dispatch({
|
|
@@ -159694,9 +159756,9 @@ var bundle$8 = {
|
|
|
159694
159756
|
});
|
|
159695
159757
|
}, false);
|
|
159696
159758
|
|
|
159697
|
-
|
|
159698
|
-
|
|
159699
|
-
legendLayers[uid] = [
|
|
159759
|
+
_img3.alt = "Style for ".concat(displayName);
|
|
159760
|
+
_img3.crossOrigin = "anonymous";
|
|
159761
|
+
legendLayers[uid] = [_img3]; //TODO: Update to possibly push multiple images into array
|
|
159700
159762
|
|
|
159701
159763
|
dispatch({
|
|
159702
159764
|
type: "LEGEND_LAYERS_UPDATED",
|
|
@@ -159704,41 +159766,41 @@ var bundle$8 = {
|
|
|
159704
159766
|
legendLayers: legendLayers
|
|
159705
159767
|
}
|
|
159706
159768
|
});
|
|
159707
|
-
} else if (drawingInfo.renderer.symbol.type === "esriSMS") {
|
|
159708
|
-
var
|
|
159769
|
+
} else if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriSMS") {
|
|
159770
|
+
var _img4 = new Image();
|
|
159709
159771
|
|
|
159710
|
-
var
|
|
159772
|
+
var _outlineColor2 = drawingInfo.renderer.symbol.outline.color;
|
|
159711
159773
|
var outlineWidth = drawingInfo.renderer.symbol.outline.width;
|
|
159712
|
-
var
|
|
159774
|
+
var _fillColor2 = drawingInfo.renderer.symbol.color;
|
|
159713
159775
|
var size = drawingInfo.renderer.symbol.size;
|
|
159714
159776
|
|
|
159715
|
-
var
|
|
159777
|
+
var _canvas3 = document.createElement("canvas");
|
|
159716
159778
|
|
|
159717
|
-
var
|
|
159779
|
+
var _ctx3 = _canvas3.getContext("2d");
|
|
159718
159780
|
|
|
159719
|
-
|
|
159720
|
-
|
|
159721
|
-
legendCanvases[uid].widths.push(
|
|
159722
|
-
legendCanvases[uid].heights.push(
|
|
159781
|
+
_canvas3.width = 20;
|
|
159782
|
+
_canvas3.height = 20;
|
|
159783
|
+
legendCanvases[uid].widths.push(_canvas3.width);
|
|
159784
|
+
legendCanvases[uid].heights.push(_canvas3.height); // circle
|
|
159723
159785
|
|
|
159724
|
-
|
|
159786
|
+
_ctx3.beginPath();
|
|
159725
159787
|
|
|
159726
|
-
|
|
159727
|
-
|
|
159788
|
+
_ctx3.strokeStyle = "rgba(".concat(_outlineColor2.join(), ")");
|
|
159789
|
+
_ctx3.lineWidth = outlineWidth;
|
|
159728
159790
|
|
|
159729
|
-
|
|
159791
|
+
_ctx3.arc(size, size, size / 1.5, 0, Math.PI * 2);
|
|
159730
159792
|
|
|
159731
|
-
|
|
159793
|
+
_ctx3.fillStyle = "rgba(".concat(_fillColor2.join(), ")");
|
|
159732
159794
|
|
|
159733
|
-
|
|
159795
|
+
_ctx3.fill();
|
|
159734
159796
|
|
|
159735
|
-
|
|
159797
|
+
_ctx3.stroke();
|
|
159736
159798
|
|
|
159737
|
-
|
|
159799
|
+
_img4.src = _canvas3.toDataURL(); //set src using data URI from canvas
|
|
159738
159800
|
|
|
159739
|
-
|
|
159740
|
-
|
|
159741
|
-
legendCanvases[uid].canvas.push(
|
|
159801
|
+
_img4.alt = "Style for ".concat(displayName);
|
|
159802
|
+
_img4.crossOrigin = "anonymous";
|
|
159803
|
+
legendCanvases[uid].canvas.push(_canvas3);
|
|
159742
159804
|
dispatch({
|
|
159743
159805
|
type: "LEGEND_CANVAS_ADDED",
|
|
159744
159806
|
payload: {
|
|
@@ -159746,7 +159808,7 @@ var bundle$8 = {
|
|
|
159746
159808
|
loading: false
|
|
159747
159809
|
}
|
|
159748
159810
|
});
|
|
159749
|
-
legendLayers[uid].push(
|
|
159811
|
+
legendLayers[uid].push(_img4);
|
|
159750
159812
|
dispatch({
|
|
159751
159813
|
type: "LEGEND_LAYERS_UPDATED",
|
|
159752
159814
|
payload: {
|
|
@@ -159754,6 +159816,127 @@ var bundle$8 = {
|
|
|
159754
159816
|
loading: false
|
|
159755
159817
|
}
|
|
159756
159818
|
});
|
|
159819
|
+
} //___________________________________________________________________________________________________________________________________
|
|
159820
|
+
else if (drawingInfo.renderer.uniqueValueInfos) {
|
|
159821
|
+
// let canvas = document.createElement("canvas");
|
|
159822
|
+
// let ctx = canvas.getContext("2d");
|
|
159823
|
+
var result = [];
|
|
159824
|
+
drawingInfo.renderer.uniqueValueInfos.forEach(function (val) {
|
|
159825
|
+
var label = val.label;
|
|
159826
|
+
var img = new Image();
|
|
159827
|
+
img.src = "data:image/png;base64,".concat(val.symbol.imageData); // img.addEventListener(
|
|
159828
|
+
// "load",
|
|
159829
|
+
// function () {
|
|
159830
|
+
|
|
159831
|
+
var canvas = document.createElement("canvas");
|
|
159832
|
+
var ctx = canvas.getContext("2d");
|
|
159833
|
+
var labelWidth = Number(ctx.measureText(label).width); //set canvas width & height
|
|
159834
|
+
|
|
159835
|
+
canvas.width = Number(val.symbol.width) + labelWidth + 4;
|
|
159836
|
+
canvas.height = val.symbol.height; //store width & height for larger canvas calculation
|
|
159837
|
+
// legendCanvases[uid].widths.push(canvas.width);
|
|
159838
|
+
// legendCanvases[uid].heights.push(canvas.height);
|
|
159839
|
+
//set background
|
|
159840
|
+
|
|
159841
|
+
ctx.fillStyle = "white";
|
|
159842
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height); // // ctx.putImageData(val.symbol.imageData, 0,0)
|
|
159843
|
+
|
|
159844
|
+
ctx.drawImage(img, 0, 0); //add image to canvas
|
|
159845
|
+
// //add label to the right of image
|
|
159846
|
+
// ctx.font = "10px Arial";
|
|
159847
|
+
// ctx.fillStyle = "black";
|
|
159848
|
+
// ctx.fillText(label, canvas.width + 2, canvas.height / 2);
|
|
159849
|
+
// legendCanvases[uid].canvas.push(canvas);
|
|
159850
|
+
// dispatch({
|
|
159851
|
+
// type: "LEGEND_CANVAS_ADDED",
|
|
159852
|
+
// payload: {
|
|
159853
|
+
// legendCanvases: legendCanvases,
|
|
159854
|
+
// loading: false,
|
|
159855
|
+
// },
|
|
159856
|
+
// });
|
|
159857
|
+
// result.push(canvas)
|
|
159858
|
+
// },
|
|
159859
|
+
// false
|
|
159860
|
+
// );
|
|
159861
|
+
// img.src = `data:${val.symbol.url};base64,${val.symbol.imageData}`
|
|
159862
|
+
// img.src = canvas.toDataURL()
|
|
159863
|
+
|
|
159864
|
+
img.alt = "Style for ".concat(label);
|
|
159865
|
+
img.crossOrigin = "anonymous";
|
|
159866
|
+
img.title = label; // legendLayers[uid] = [img]; //TODO: Update to possibly push multiple images into array
|
|
159867
|
+
// images.push(img)
|
|
159868
|
+
// dispatch({
|
|
159869
|
+
// type: "LEGEND_LAYERS_UPDATED",
|
|
159870
|
+
// payload: {
|
|
159871
|
+
// legendLayers: legendLayers,
|
|
159872
|
+
// },
|
|
159873
|
+
// });
|
|
159874
|
+
|
|
159875
|
+
result.push({
|
|
159876
|
+
canvas: canvas,
|
|
159877
|
+
image: img
|
|
159878
|
+
});
|
|
159879
|
+
});
|
|
159880
|
+
result.forEach(function (item) {
|
|
159881
|
+
item.image.alt = "Style for ".concat(lyr.displayName);
|
|
159882
|
+
legendCanvases[lyr.uid].widths.push(item.canvas.width);
|
|
159883
|
+
legendCanvases[lyr.uid].heights.push(item.canvas.height);
|
|
159884
|
+
legendCanvases[lyr.uid].canvas.push(item.canvas);
|
|
159885
|
+
legendLayers[lyr.uid].push(item.image);
|
|
159886
|
+
dispatch({
|
|
159887
|
+
type: "LEGEND_CANVAS_ADDED",
|
|
159888
|
+
payload: {
|
|
159889
|
+
legendCanvases: legendCanvases,
|
|
159890
|
+
loading: false
|
|
159891
|
+
}
|
|
159892
|
+
});
|
|
159893
|
+
});
|
|
159894
|
+
} else if (drawingInfo.renderer.classBreakInfos) {
|
|
159895
|
+
drawingInfo.renderer.classBreakInfos.forEach(function (val) {
|
|
159896
|
+
var img = new Image();
|
|
159897
|
+
var outlineColor = val.symbol.outline.color;
|
|
159898
|
+
var outlineWidth = val.symbol.outline.width;
|
|
159899
|
+
var fillColor = val.symbol.color;
|
|
159900
|
+
var size = val.symbol.size;
|
|
159901
|
+
var canvas = document.createElement("canvas");
|
|
159902
|
+
var ctx = canvas.getContext("2d");
|
|
159903
|
+
canvas.width = 20 * 2.5;
|
|
159904
|
+
canvas.height = 20;
|
|
159905
|
+
legendCanvases[uid].widths.push(canvas.width);
|
|
159906
|
+
legendCanvases[uid].heights.push(canvas.height); //text
|
|
159907
|
+
|
|
159908
|
+
ctx.font = "11px Arial";
|
|
159909
|
+
ctx.fillText(val.label, size * 3, size * 2, 30); // circle
|
|
159910
|
+
|
|
159911
|
+
ctx.beginPath();
|
|
159912
|
+
ctx.strokeStyle = "rgba(".concat(outlineColor.join(), ")");
|
|
159913
|
+
ctx.lineWidth = outlineWidth;
|
|
159914
|
+
ctx.arc(size, size * 1.5, size / 1.5, 0, Math.PI * 2);
|
|
159915
|
+
ctx.fillStyle = "rgba(".concat(fillColor.join(), ")");
|
|
159916
|
+
ctx.fill();
|
|
159917
|
+
ctx.stroke();
|
|
159918
|
+
img.src = canvas.toDataURL(); //set src using data URI from canvas
|
|
159919
|
+
|
|
159920
|
+
img.alt = "Style for ".concat(displayName);
|
|
159921
|
+
img.crossOrigin = "anonymous";
|
|
159922
|
+
debugger;
|
|
159923
|
+
legendCanvases[uid].canvas.push(canvas);
|
|
159924
|
+
dispatch({
|
|
159925
|
+
type: "LEGEND_CANVAS_ADDED",
|
|
159926
|
+
payload: {
|
|
159927
|
+
legendCanvases: legendCanvases,
|
|
159928
|
+
loading: false
|
|
159929
|
+
}
|
|
159930
|
+
});
|
|
159931
|
+
legendLayers[uid].push(img);
|
|
159932
|
+
dispatch({
|
|
159933
|
+
type: "LEGEND_LAYERS_UPDATED",
|
|
159934
|
+
payload: {
|
|
159935
|
+
legendLayers: legendLayers,
|
|
159936
|
+
loading: false
|
|
159937
|
+
}
|
|
159938
|
+
});
|
|
159939
|
+
});
|
|
159757
159940
|
} else {
|
|
159758
159941
|
legendLayers[uid] = ["Legend not available!"];
|
|
159759
159942
|
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,65 @@ export default {
|
|
|
259
263
|
loading: false,
|
|
260
264
|
},
|
|
261
265
|
});
|
|
262
|
-
}
|
|
266
|
+
}
|
|
267
|
+
else if(
|
|
268
|
+
drawingInfo.renderer.symbol &&
|
|
269
|
+
drawingInfo.renderer.symbol.type === "esriSFS" &&
|
|
270
|
+
drawingInfo.renderer.symbol.style === "esriSFSBackwardDiagonal"
|
|
271
|
+
) {
|
|
272
|
+
// debugger
|
|
273
|
+
let img = new Image();
|
|
274
|
+
const outlineColor = drawingInfo.renderer.symbol.outline.color;
|
|
275
|
+
const fillColor = drawingInfo.renderer.symbol.color;
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
let canvas = document.createElement("canvas");
|
|
279
|
+
let ctx = canvas.getContext("2d");
|
|
280
|
+
|
|
281
|
+
canvas.width = 20;
|
|
282
|
+
canvas.height = 20;
|
|
283
|
+
|
|
284
|
+
//store width & height for larger canvas calculation
|
|
285
|
+
legendCanvases[uid].widths.push(canvas.width);
|
|
286
|
+
legendCanvases[uid].heights.push(canvas.height);
|
|
287
|
+
|
|
288
|
+
// // Draw polygon
|
|
289
|
+
ctx.beginPath();
|
|
290
|
+
ctx.moveTo(0, 10);
|
|
291
|
+
ctx.lineTo(10, 0);
|
|
292
|
+
ctx.moveTo(0, 20);
|
|
293
|
+
ctx.lineTo(20, 0);
|
|
294
|
+
ctx.moveTo(10, 20);
|
|
295
|
+
ctx.lineTo(20, 10);
|
|
296
|
+
ctx.lineWidth = "2";
|
|
297
|
+
ctx.strokeStyle = `rgba(${outlineColor.join()})`;
|
|
298
|
+
ctx.rect(0, 0, 20, 20);
|
|
299
|
+
ctx.stroke();
|
|
300
|
+
|
|
301
|
+
img.src = canvas.toDataURL(); //set src using data URI from canvas
|
|
302
|
+
img.alt = `Style for ${displayName}`;
|
|
303
|
+
img.crossOrigin = "anonymous";
|
|
304
|
+
|
|
305
|
+
legendCanvases[uid].canvas.push(canvas);
|
|
306
|
+
dispatch({
|
|
307
|
+
type: "LEGEND_CANVAS_ADDED",
|
|
308
|
+
payload: {
|
|
309
|
+
legendCanvases: legendCanvases,
|
|
310
|
+
loading: false,
|
|
311
|
+
},
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
legendLayers[uid].push(img);
|
|
315
|
+
dispatch({
|
|
316
|
+
type: "LEGEND_LAYERS_UPDATED",
|
|
317
|
+
payload: {
|
|
318
|
+
legendLayers: legendLayers,
|
|
319
|
+
loading: false,
|
|
320
|
+
},
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
//____________________________________________________________________________________________________________________________________
|
|
324
|
+
else if (
|
|
263
325
|
drawingInfo.renderer.type === "uniqueValue" &&
|
|
264
326
|
drawingInfo.renderer.uniqueValueInfos
|
|
265
327
|
) {
|
|
@@ -424,7 +486,7 @@ export default {
|
|
|
424
486
|
}
|
|
425
487
|
break;
|
|
426
488
|
case "esriGeometryPoint":
|
|
427
|
-
if (drawingInfo.renderer.symbol.type === "esriPMS") {
|
|
489
|
+
if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriPMS") {
|
|
428
490
|
let img = new Image();
|
|
429
491
|
img.src = `data:image/png;base64,${data.drawingInfo.renderer.symbol.imageData}`;
|
|
430
492
|
img.addEventListener(
|
|
@@ -468,7 +530,7 @@ export default {
|
|
|
468
530
|
legendLayers: legendLayers,
|
|
469
531
|
},
|
|
470
532
|
});
|
|
471
|
-
} else if (drawingInfo.renderer.symbol.type === "esriSMS") {
|
|
533
|
+
} else if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriSMS") {
|
|
472
534
|
let img = new Image();
|
|
473
535
|
const outlineColor = drawingInfo.renderer.symbol.outline.color;
|
|
474
536
|
const outlineWidth = drawingInfo.renderer.symbol.outline.width;
|
|
@@ -514,7 +576,154 @@ export default {
|
|
|
514
576
|
loading: false,
|
|
515
577
|
},
|
|
516
578
|
});
|
|
517
|
-
}
|
|
579
|
+
}
|
|
580
|
+
//___________________________________________________________________________________________________________________________________
|
|
581
|
+
else if (drawingInfo.renderer.uniqueValueInfos){
|
|
582
|
+
// let canvas = document.createElement("canvas");
|
|
583
|
+
// let ctx = canvas.getContext("2d");
|
|
584
|
+
let result = []
|
|
585
|
+
let images = []
|
|
586
|
+
drawingInfo.renderer.uniqueValueInfos.forEach((val) => {
|
|
587
|
+
|
|
588
|
+
let label = val.label
|
|
589
|
+
let wkCanvas;
|
|
590
|
+
let img = new Image();
|
|
591
|
+
img.src = `data:image/png;base64,${val.symbol.imageData}`;
|
|
592
|
+
|
|
593
|
+
// img.addEventListener(
|
|
594
|
+
// "load",
|
|
595
|
+
// function () {
|
|
596
|
+
let canvas = document.createElement("canvas");
|
|
597
|
+
let ctx = canvas.getContext("2d")
|
|
598
|
+
|
|
599
|
+
const labelWidth = Number(ctx.measureText(label).width);
|
|
600
|
+
|
|
601
|
+
//set canvas width & height
|
|
602
|
+
canvas.width = Number(val.symbol.width) + labelWidth + 4;
|
|
603
|
+
canvas.height = val.symbol.height;
|
|
604
|
+
|
|
605
|
+
//store width & height for larger canvas calculation
|
|
606
|
+
// legendCanvases[uid].widths.push(canvas.width);
|
|
607
|
+
// legendCanvases[uid].heights.push(canvas.height);
|
|
608
|
+
|
|
609
|
+
//set background
|
|
610
|
+
ctx.fillStyle = "white";
|
|
611
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
612
|
+
// // ctx.putImageData(val.symbol.imageData, 0,0)
|
|
613
|
+
|
|
614
|
+
ctx.drawImage(img, 0, 0); //add image to canvas
|
|
615
|
+
|
|
616
|
+
// //add label to the right of image
|
|
617
|
+
// ctx.font = "10px Arial";
|
|
618
|
+
// ctx.fillStyle = "black";
|
|
619
|
+
|
|
620
|
+
// ctx.fillText(label, canvas.width + 2, canvas.height / 2);
|
|
621
|
+
|
|
622
|
+
// legendCanvases[uid].canvas.push(canvas);
|
|
623
|
+
|
|
624
|
+
// dispatch({
|
|
625
|
+
// type: "LEGEND_CANVAS_ADDED",
|
|
626
|
+
// payload: {
|
|
627
|
+
// legendCanvases: legendCanvases,
|
|
628
|
+
// loading: false,
|
|
629
|
+
// },
|
|
630
|
+
// });
|
|
631
|
+
// result.push(canvas)
|
|
632
|
+
// },
|
|
633
|
+
// false
|
|
634
|
+
// );
|
|
635
|
+
// img.src = `data:${val.symbol.url};base64,${val.symbol.imageData}`
|
|
636
|
+
// img.src = canvas.toDataURL()
|
|
637
|
+
|
|
638
|
+
img.alt = `Style for ${label}`;
|
|
639
|
+
img.crossOrigin = "anonymous";
|
|
640
|
+
img.title = label;
|
|
641
|
+
// legendLayers[uid] = [img]; //TODO: Update to possibly push multiple images into array
|
|
642
|
+
// images.push(img)
|
|
643
|
+
|
|
644
|
+
// dispatch({
|
|
645
|
+
// type: "LEGEND_LAYERS_UPDATED",
|
|
646
|
+
// payload: {
|
|
647
|
+
// legendLayers: legendLayers,
|
|
648
|
+
// },
|
|
649
|
+
// });
|
|
650
|
+
result.push({
|
|
651
|
+
canvas: canvas,
|
|
652
|
+
image: img,
|
|
653
|
+
});
|
|
654
|
+
|
|
655
|
+
});
|
|
656
|
+
result.forEach((item) => {
|
|
657
|
+
item.image.alt = `Style for ${lyr.displayName}`;
|
|
658
|
+
legendCanvases[lyr.uid].widths.push(item.canvas.width);
|
|
659
|
+
legendCanvases[lyr.uid].heights.push(item.canvas.height);
|
|
660
|
+
legendCanvases[lyr.uid].canvas.push(item.canvas);
|
|
661
|
+
legendLayers[lyr.uid].push(item.image);
|
|
662
|
+
|
|
663
|
+
dispatch({
|
|
664
|
+
type: "LEGEND_CANVAS_ADDED",
|
|
665
|
+
payload: {
|
|
666
|
+
legendCanvases: legendCanvases,
|
|
667
|
+
loading: false,
|
|
668
|
+
},
|
|
669
|
+
});
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
else if (drawingInfo.renderer.classBreakInfos){
|
|
674
|
+
drawingInfo.renderer.classBreakInfos.forEach((val) => {
|
|
675
|
+
let img = new Image();
|
|
676
|
+
const outlineColor = val.symbol.outline.color;
|
|
677
|
+
const outlineWidth = val.symbol.outline.width;
|
|
678
|
+
const fillColor = val.symbol.color;
|
|
679
|
+
const size = val.symbol.size;
|
|
680
|
+
let canvas = document.createElement("canvas");
|
|
681
|
+
let ctx = canvas.getContext("2d");
|
|
682
|
+
|
|
683
|
+
canvas.width = 20 * 2.5;
|
|
684
|
+
canvas.height = 20;
|
|
685
|
+
|
|
686
|
+
legendCanvases[uid].widths.push(canvas.width);
|
|
687
|
+
legendCanvases[uid].heights.push(canvas.height);
|
|
688
|
+
|
|
689
|
+
//text
|
|
690
|
+
ctx.font = "11px Arial";
|
|
691
|
+
ctx.fillText(val.label ,size * 3 , size * 2 , 30);
|
|
692
|
+
|
|
693
|
+
// circle
|
|
694
|
+
ctx.beginPath();
|
|
695
|
+
ctx.strokeStyle = `rgba(${outlineColor.join()})`;
|
|
696
|
+
ctx.lineWidth = outlineWidth;
|
|
697
|
+
ctx.arc(size, size * 1.5, size/1.5, 0, Math.PI * 2);
|
|
698
|
+
ctx.fillStyle = `rgba(${fillColor.join()})`;
|
|
699
|
+
ctx.fill();
|
|
700
|
+
ctx.stroke();
|
|
701
|
+
|
|
702
|
+
img.src = canvas.toDataURL(); //set src using data URI from canvas
|
|
703
|
+
img.alt = `Style for ${displayName}`;
|
|
704
|
+
img.crossOrigin = "anonymous";
|
|
705
|
+
debugger
|
|
706
|
+
|
|
707
|
+
legendCanvases[uid].canvas.push(canvas);
|
|
708
|
+
dispatch({
|
|
709
|
+
type: "LEGEND_CANVAS_ADDED",
|
|
710
|
+
payload: {
|
|
711
|
+
legendCanvases: legendCanvases,
|
|
712
|
+
loading: false,
|
|
713
|
+
},
|
|
714
|
+
});
|
|
715
|
+
|
|
716
|
+
legendLayers[uid].push(img);
|
|
717
|
+
dispatch({
|
|
718
|
+
type: "LEGEND_LAYERS_UPDATED",
|
|
719
|
+
payload: {
|
|
720
|
+
legendLayers: legendLayers,
|
|
721
|
+
loading: false,
|
|
722
|
+
},
|
|
723
|
+
});
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
else {
|
|
518
727
|
legendLayers[uid] = ["Legend not available!"];
|
|
519
728
|
dispatch({
|
|
520
729
|
type: "LEGEND_LAYERS_UPDATE_ERROR",
|