So I am writing (trying) Arcade code for ArcGIS Online Web Map that will create a hyperlink in a pop-up of one feature layer, which when clicked, will turn on another feature layer in the same map.
I have two layers:
I'm trying to use ArcGIS Online's URL scheme for layer visibility through the URL parameters. Layer A and Layer B each have IDs from their AGOL web pages I have copied.
Here is my code:
var orgUrl = "https://www.arcgis.com"; // Define the Web Map ID var webMapId = "0b0c9d09e20a4c1fb6707a51c5e2bd51"; // Define the Layer B ID var layerBId = "0b0c9d09e20a4c1fb6707a51c5e2bd51"; // Construct the URL with parameters to turn on Layer B var layerBUrl = orgUrl + "/home/webmap/viewer.html?webmap=" + webMapId + "&layers=" + layerBId; // Define the hyperlink text var hyperlinkText = "Turn on Layer B"; // Return the HTML code for the hyperlink return "<a href='" + layerBUrl + "' target='_blank'>" + hyperlinkText + "</a>";
What I get is a hyperlink that opens a new web map. I'm just trying to create a hyperlink in a feature layer's pop-up that turns on a different feature layer in the same map.
Any assistance would be greatly appreciated. Thank you.
Solved! Go to Solution.
That's how it's meant to work. Custom URL links are designed for a separate web page, not the current one.
There may be a world where you could force it to open the new page in the current one, instead of a new tab/window, but the current session for the user might be lost.
Within map viewer there aren't tools for dynamic layer on/off interaction.
Generally, you shouldn't share web maps with users. Better to wrap it in an app. In this case you could use Dashboards or Experience Builder. They'll give you more options for dynamic layer interaction.
That's how it's meant to work. Custom URL links are designed for a separate web page, not the current one.
There may be a world where you could force it to open the new page in the current one, instead of a new tab/window, but the current session for the user might be lost.
Within map viewer there aren't tools for dynamic layer on/off interaction.
Generally, you shouldn't share web maps with users. Better to wrap it in an app. In this case you could use Dashboards or Experience Builder. They'll give you more options for dynamic layer interaction.
Thank you. I guess it's not possible right now in AGOL Map Viewer to toggle layers in a map on and off within a pop-up.