Hello, I have a 3D local scene which contains a map-image layer that contains about 30 sublayers. There's no option to turn on the popup on the sublayers when config it in the scene, therefore the popup didn't show up when bring the scene view in my JS API app. I'm wondering if there's way to enable popup for map-image sublayers in scene via JS API? thank you
Hi @JackFanZhang -
You can configure the PopupTemplate on the MapImageLayer sublayers. Here's a simple example on how to do this with a scene from ArcGIS Online: https://codepen.io/laurenb14/pen/ZEojwQW?editors=1000
Hope this helps!
Thank you very much @LaurenBoyd
Appreciate for sharing the code. Good to learn this could be done by supplying the feature layer with a new PopupTemplate object. The challenge I had was also about how to show the popup using the default template, which display all the visible attributes. With the suggested method, I would need to populate the contents for all sublayers (there're 40 of them in my case). Technically it is possible but need to write a bit extra code. Anyway I ended up doing this by manually load the feature layer then assign the layer's defaultPopupTempalte to the popupTemplate property, which works as expected.
subLayer.load().then(()=>{
subLayer.popupEnabled = true;
subLayer.popupTemplate = subLayer.defaultPopupTemplate
})