Include javacript in popups of an existing web map created using Map Viewer

277
0
08-15-2022 09:14 AM
KhoaPham
New Contributor II

Hello all!

I have a use case that calls for making an API call to a document management system (OTIS) to retrieve URLs of documents in OTIS and display in the popup of a clicked feature of a web map.  The GISID of the feature is passed in the API call that searches OTIS for the docs corresponding to that GISID.  The API call requires authentication so I cannot use Arcade.

The web map is an existing web map (let's call it Wastewater) that was created using the enterprise portal Map Viewer.  I was able to load Wastewater in a staging page using webmap.load() and include code in the staging page to dynamically handle a click on a feature to return the corresponding document URLs from OTIS.  I included a webmap.save() in the code.  The result is, after launching the page, clicking some features and verifying that the correct doc URLs corresponding to the clicked features returned by OTIS and displayed in the popups, what is saved in the Wastewater web map popup configuration is the URLs of the last feature I clicked on.  I.e. when I look at the web map's popup configuration in the Portal Map Viewer, I see the URLs of the last feature click on.  

My question is would the portal Map Viewer popup configuration be able to store the javascript needed to handle the above API call?  Is there a way to insert javascript code into the portal Map Viewer and have it saved in there?  I tried pasting my javascript in the web map's sublayer popup configuration's Custom Attribute Display window as html source code (with the appropriate <script> tags of course), but the codes won't save.  The codes would disappear from the Custom Attribute Display window when I open it again.

Any help or tips on how to implement my use case on an existing web map would be greatly appreciated.  I am trying to avoid recreating, using code, the entire web map which has many sublayers requiring tedious popups and widgets configurations through code.

Tags (3)
0 Kudos
0 Replies