programatically show popup for specific (invisible) layer?

367
5
Jump to solution
02-05-2021 03:05 AM
Labels (2)
MattiasEkström
Regular Contributor

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?

0 Kudos
2 Solutions

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Mattias,

   You set the popups feature array before you show the popup.

 

this.map.infoWindow.setFeatures([your graphic object from your layer]);

 

View solution in original post

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

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.

View solution in original post

0 Kudos
5 Replies
LeninVladimirMoralesOñate
New Contributor

OK THANKS

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Mattias,

   You set the popups feature array before you show the popup.

 

this.map.infoWindow.setFeatures([your graphic object from your layer]);

 

View solution in original post

0 Kudos
MattiasEkström
Regular Contributor

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...  

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

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.

View solution in original post

0 Kudos
MattiasEkström
Regular Contributor

Thanks Robert! I think got it from here. Anyway the original question is answered.

0 Kudos