I have an ArcGIS.js 3.22 application that loads a number of FeatureLayers in a map and then constructs and loads a number of GraphicsLayers. I have a click event that runs an IdentifyTask on each of the FeatureLayers in the map. It's nice because the identify task loads feature information for overlapping layers into the infoTemplate. The user is able to click the infoTemplate's arrow and cycle through features identified across all featureLayers present at a click point.
I would like to include graphicsLayer information into the infoTemplate along with featureLayer information so that the user may loop over all features returned by their mouse click. I want the infoTemplate to show attribute information from both the featureLayers and the graphicsLayers.
Is this possible? Dose anyone have an idea of how this would be done? It looks like ArcGIS.js 4.5 allows you to greate feature layers from graphics using the graphicsLayer's 'source' property. Can the source property in 3.22 be used similarly?
Thanks, Tyler
Solved! Go to Solution.
Its still dying at map.infoWindow.setFeatures(graphicsLayerFeatures); The JSON for graphicsLayerFeatures looks like:
[{"geometry":{"type":"polygon","rings":[[[-8768009.64172613,4252914.910190374],[-8768007.41799213,4253855.89837671],[-8767070.558637924,4253853.624670654],[-8767072.86179002,4252912.636868052],[-8768009.64172613,4252914.910190374]]],"_ring":0,"spatialReference":{"wkid":102100,"latestWkid":3857}},"symbol":null,"attributes":{"OBJECTID":"530","Grid":"67913","SHAPE":"Polygon","GlobalID":"{BA7BB332-5E11-404A-A37F-0C7F0F8E5E89}","SHAPE.STArea()":"6249760.10791","SHAPE.STLength()":"9999.808084","layerName":"Utility Grid"},"infoTemplate":{"title":"AREANAME","content":"OBJECTID: 530<br/> Grid: 67913<br/> GlobalID: {BA7BB332-5E11-404A-A37F-0C7F0F8E5E89}<br/> "}},{"geometry":{"type":"point","x":-8767571.07357861,"y":4253201.3693682095,"spatialReference":{"wkid":102100}},"attributes":{"Type":"Water Meter Asset","Name":"Meter: 73186851","Id":"02i0x00000054jOAAQ"},"infoTemplate":{"title":"Water Meter Asset","content":"Type: ${Type} <br/>Name: ${Name} <br/><span class='link' onclick='LinkAsset(\"02i0x00000054jOAAQ\",\"Salesforce\")'>Link Asset</span>"},"symbol":null},{"geometry":{"type":"polygon","rings":[[[-8768009.64172613,4252914.910190374],[-8768007.41799213,4253855.89837671],[-8767070.558637924,4253853.624670654],[-8767072.86179002,4252912.636868052],[-8768009.64172613,4252914.910190374]]],"_ring":0,"spatialReference":{"wkid":102100,"latestWkid":3857}},"symbol":null,"attributes":{"OBJECTID":"530","Grid":"67913","SHAPE":"Polygon","GlobalID":"{BA7BB332-5E11-404A-A37F-0C7F0F8E5E89}","SHAPE.STArea()":"6249760.10791","SHAPE.STLength()":"9999.808084","layerName":"Utility Grid"},"infoTemplate":{"title":"AREANAME","content":"OBJECTID: 530<br/> Grid: 67913<br/> GlobalID: {BA7BB332-5E11-404A-A37F-0C7F0F8E5E89}<br/> "}},{"geometry":{"type":"point","x":-8767570.516981157,"y":4253194.793324914,"spatialReference":{"wkid":102100}},"attributes":{"Type":"Water Meter Asset","Name":"Meter: 73193287","Id":"02i0x00000054jHAAQ"},"infoTemplate":{"title":"Water Meter Asset","content":"Type: ${Type} <br/>Name: ${Name} <br/><span class='link' onclick='LinkAsset(\"02i0x00000054jHAAQ\",\"Salesforce\")'>Link Asset</span>"},"symbol":null}]
Any ideas?
Tyler,
What do you mean by dying? What is the error saying?
The error I'm getting is:
Uncaught TypeError: a.getLayer is not a function
at Object.<anonymous> (init.js:1179)
at Object.forEach (init.js:70)
at Object._processFeatures (init.js:1179)
at Object.<anonymous> (init.js:63)
at Object.<anonymous> (init.js:644)
at Object.c [as onSetFeatures] (init.js:119)
at Object._updateFeatures (init.js:1178)
at Object.setFeatures (init.js:1171)
at Object.n (init.js:157)
at Object.setFeatures (init.js:1137)
Thanks, Tyler
Thanks, I believe that I'm getting close. However, I don't understand how to get a reference to the clicked graphic in my map's on click event. For the featureLayers I perform and identifyTask to populate my featureArray with the features returned by my click event. How would I get a reference to the graphics that are returned by the click event?
Thanks, Tyler
I think I figured it out. The graphicsLayer click fires before the map click. I'll create a graphicsLayer 'features' object in the graphicsLayer click and pick them up in the mapClick. Thanks, Tyler