I've a custom widget where I have a context menu to the map. From one of the menu items I want to display information from a specific layer where the user clicked. I have the map point and can open the popup-window with this.map.infoWindow.show(clickedPoint);
But it just shows an empty popUp. I have the layer (but turned off) in my web map with configured popup. Is there some easy way to populate the infoWindow with my already configured PopUp for that layer?
Or do have to query the layer and populate the info-window from scratch with map.infoWindow.setContent or something like that? And could that mess up the ordinary PopUps somehow?
Solved! Go to Solution.
Mattias,
You set the popups feature array before you show the popup.
this.map.infoWindow.setFeatures([your graphic object from your layer]);
Mattias,
Yes a query to the server is how esri handles Map Image Layer sub layer popups currently. So you would need to do the same. To get the infoTemplate for this sub layer you would use the infoTemplates property of the layer
https://developers.arcgis.com/javascript/3/jsapi/arcgisdynamicmapservicelayer-amd.html#infotemplates
The graphic returned from the queryTask may not have the infoTemplate property set so you will have to set it before you send the graphic to the popup feature array.
OK THANKS
Mattias,
You set the popups feature array before you show the popup.
this.map.infoWindow.setFeatures([your graphic object from your layer]);
Thanks Robert, turns out it wasn't that easy to get my layer after all. hade some problem with map.getLayer until I realized that the LayerId is some cryptic [myLayername]_XXX. However my layer isn't a featureLayer, it's a sublayer in a Map Image Layers. So I guess I have to make a query anyway to get a grafic object to put in setFeatures[], right?
But it seems I should be able to get the InfoTemplate from the map, that would help...
Mattias,
Yes a query to the server is how esri handles Map Image Layer sub layer popups currently. So you would need to do the same. To get the infoTemplate for this sub layer you would use the infoTemplates property of the layer
https://developers.arcgis.com/javascript/3/jsapi/arcgisdynamicmapservicelayer-amd.html#infotemplates
The graphic returned from the queryTask may not have the infoTemplate property set so you will have to set it before you send the graphic to the popup feature array.
Thanks Robert! I think got it from here. Anyway the original question is answered.