Enable popup by default programatically on Dynamic Service (Local Layer Widget Related)?

3174
7
08-17-2016 07:10 AM
TimDine
Occasional Contributor II

I'm attempting to enable popups on layers in an ArcGISDynamicMapServiceLayer programmatically.  Ultimately I'd like to move this code into the LocalLayer widget.  I've gotten something working for feature layers, but I'm struggling a bit on layers within MapServices.  I'm digging into LayerInfoForDefaultService.js now and am trying to figure out the path. 

It looks like you can't call enablepopup() on those layers until they have infotemplates loaded.  I'm going to try including an infotemplate in the locallayer configuration.  I'm hunting through the code that is called when I hit the dropdown for the layer for the first time (it appears to populate the info template at that time if it's blank). 

Does anyone have any sample code or suggestions / experience with attempting to do this same thing?  Even if you've attempted and gotten stumped it could be helpful.

Thanks

0 Kudos
7 Replies
TimDine
Occasional Contributor II

With some more experimenting I've realized that popups are already enabled by default for map service layers IF you've configured a popup for that layer.  I'd like to get the same behavior without having to put every field into the config file.  Ideally I'd like to put a single item (like popup: default or popup: true) and get the full default popup.  Then I can configure the ones I want in there by exception rather than all of them.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Tim,

   Have you tried to add a PopupTemplate (i.e. layer.infoTemplate = new PopupTemplate();) before the layer is added to the map?

0 Kudos
GarrettMcBride
New Contributor III

Hi Robert/Tim,

Did anyone get this figured out?  I would also like to set all layers to pop up by default.  We are constantly removing and adding layers and republishing. It would be awesome if all layers had this ability by default instead of revisting WAB 2-3x a week.

Kade

by Anonymous User
Not applicable

Garrett McBride‌ do you mean when you republish it kills all thepopups? We have that.  I use the popups through AGOL but Arc Server 10.2 and older, it kills them all. I spend many hours point and clicking Enable Popup.  

Please vote for this idea for AGOL if you'd like to see this on webmap popups: Webmaps - a 'turn all popups on' button 

Yes I know this is for dynamic layers locally which would get around this and I'll be following this thread with interest as well.  I have not used locallayer widget yet but might if this gets solved before Esri gets around to the above idea, which is probably quite likely)

0 Kudos
GarrettMcBride
New Contributor III

Hi Kevin,

I was meaning when i republish and add new layers the pop-ups for those layers aren't configured.  So the new layers don't have pop-ups enabled when the older ones do (from initial deployment in WAB).  The end users ask, why can I click on these layers and get info but not these other ones?  So I'm thinking about removing it all together and having them enable each layer as they need it.  We are constantly adding/updating layers so this will be a big problem for me.

Unfortunately I am not using AGOL so that will not help me.  We have a 12 VM ArcGIS server infrastructure and only loaded portal to get WAB to work.  All services being used are being used directly from our own AGS's using the locallayer widget. 

I am looking into this:

https://community.esri.com/thread/159817

The coding is outside my realm of knowledge but I have passed it along to our developer to see if this is an option for our current workflow.

Thanks for the quick response!  Let me know if you have any ideas/suggestions.

Kade

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

All,

   This thread may be of interest to you. I detail how to enable popups for ALL layer in WAB by default.

https://community.esri.com/message/638227-re-layer-list-enable-popub-by-default 

by Anonymous User
Not applicable

Thank you!