Hi. I'm trying to use map.infoWindow.setFeatures(). Does anyone know where I can view the documentationz? It's not listed in the InfoWindow help documentation. I want to know what the arguments are. Thanks, Tyler
Tyler,
The default class of the Map.infoWindow is a Popup dijit.
Popup | API Reference | ArcGIS API for JavaScript 3.22
That was it. I now have my graphicsLayers and featureLayers reporting in the same popup.
So because of your code above when you do graphicFeature = {}; this is a vanilla object and not an actual graphic and this does not have a layer associated with it any more and thus the error you are getting. You need to add the actual graphic object to the graphicsLayerFeatures array or create a new Graphic object and add it to the map.graphics.
Hi Robert, the graphics are contained in a graphicsLayer in the map. I have an 'on click' event on the graphicsLayer. The graphicsLayer 'on click' event is used to populate an array of features (graphicsLayerFeatures) returned by the event:
graphicsLayer.on("click", function(event){
var graphicFeature = {}; graphicFeature.geometry = event.graphic.geometry; graphicFeature.attributes = event.graphic.attributes; graphicFeature.infoTemplate = event.graphic.infoTemplate; var sms = new SimpleMarkerSymbol().setStyle(SimpleMarkerSymbol.STYLE_SQUARE).setColor(new Color([255,0,0,0.5])); graphicFeature.symbol = sms; graphicsLayerFeatures.push(graphicFeature);
}
I am attempting to add to graphicsLayerFeatures later in the event chain to add features returned by a an identify task performed on a number of feature layers. I want to combine info from both graphicsLayers and featureLayers in my popup so that the user may seamlessly iterate over the results from both layer types using the popup's left and right arrows.
So the question is have you added that graphic to a layer in the map then?
Hi Robert, The documentation for the Popup digit says that the required parameters are features. The features are an array of features or deferreds (i.e. Graphic[ ], Deferred[ ]). However, I am only able to pass a single graphic to this method in testing. For example, I have the following graphic array:
var graphicsLayerFeatures = [{"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":{"style":"square","color":{"r":255,"g":0,"b":0,"a":0.5},"size":16,"outline":{"width":1.3333333333333333,"color":{"r":0,"g":0,"b":0,"a":1},"style":"solid"}}}]
If I pass this graphics array with one graphic in it (i.e. map.infoWindow.setFeatures(graphicsLayerFeatures)) map.infoWindow.setFeatures() fails with an error of:
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)
However, if I pass only a graphic to map.infoWindow.setFeatures(i.e. map.infoWindow.setFeatures(graphicsLayerFeatures[0]) then map.infoWindow.setFeatures() succeeds.
How do I set more than on feature using map.infoWindow.setFeatures?
Thanks, Tyler
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.