Select to view content in your preferred language

Arcade Popups with multiple web links

679
4
Jump to solution
08-30-2022 10:35 AM
Labels (1)
John_Shell
New Contributor III

I need to be able to show data with a one to many relationship. I have the data coming out correctly but the links are merging together into one web link. I need the links to be individual links.

0 Kudos
2 Solutions

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

This is the map we're talking about: Tacoma City Council Districts Web Map Update-Copy (arcgis.com)

 

The old and hard way:

  • figure out how many links you need at max
    • let's say the biggest district has 5 neighbothood counlics, then you need 5 links.
  • create the expressions:
    • for each council: 1 expression for the name, 1 for the url
  • create the popup

 

// Expression for the name
index = 0  // <- change this number in each name expression

var areas =FeatureSetByName($map,"Neighborhood Council Districts (Tacoma)");
var Onefifty = Buffer($Feature, -150, 'feet')
var countp = Intersects(areas,Onefifty);

var i = 0
for(var c in countp) {
    if(i == index) {
        return c.Neighborhood
    }
    i++
}
return ''
// Expression for the url
index = 0  // <- change this number in each name expression

var areas =FeatureSetByName($map,"Neighborhood Council Districts (Tacoma)");
var Onefifty = Buffer($Feature, -150, 'feet')
var countp = Intersects(areas,Onefifty);

var i = 0
for(var c in countp) {
    if(i == index) {
        return c.URL
    }
    i++
}
return ''

 

Your popup would look like this: 

JohannesLindner_0-1662619015863.png

 

 

The new and far better way: Just use an Arcade element! With this element, you can return HTML code which will be interpreted by the popup.

JohannesLindner_1-1662619126139.png

 

var areas =FeatureSetByName($map,"Neighborhood Council Districts (Tacoma)");
var Onefifty = Buffer($Feature, -150, 'feet')
var countp = Intersects(areas,Onefifty);

var result = "";
for (var item in countp){
    var name = item["Neighborhood"];
    var url = item["URL"]
    result += `<a href="${url}" target="_blank">${name}</a><br/>`
}

return { 
	type : 'text', 
	text : result
}

 


Have a great day!
Johannes

View solution in original post

John_Shell
New Contributor III

Hi Johannes,

Thank you so very much! I love seeing this work. I really want to dive deeper into Arcade and now I can learn more about Arcade elements. It all makes sense now because I had been seeing other examples of people using Html code in their Arcade code. Now I can finish up this little project and on to my next project. I hope you have a fantastic day. You have definitely made a new friend for life.

Thank you,

John

View solution in original post

0 Kudos
4 Replies
JohannesLindner
MVP Frequent Contributor

This is the map we're talking about: Tacoma City Council Districts Web Map Update-Copy (arcgis.com)

 

The old and hard way:

  • figure out how many links you need at max
    • let's say the biggest district has 5 neighbothood counlics, then you need 5 links.
  • create the expressions:
    • for each council: 1 expression for the name, 1 for the url
  • create the popup

 

// Expression for the name
index = 0  // <- change this number in each name expression

var areas =FeatureSetByName($map,"Neighborhood Council Districts (Tacoma)");
var Onefifty = Buffer($Feature, -150, 'feet')
var countp = Intersects(areas,Onefifty);

var i = 0
for(var c in countp) {
    if(i == index) {
        return c.Neighborhood
    }
    i++
}
return ''
// Expression for the url
index = 0  // <- change this number in each name expression

var areas =FeatureSetByName($map,"Neighborhood Council Districts (Tacoma)");
var Onefifty = Buffer($Feature, -150, 'feet')
var countp = Intersects(areas,Onefifty);

var i = 0
for(var c in countp) {
    if(i == index) {
        return c.URL
    }
    i++
}
return ''

 

Your popup would look like this: 

JohannesLindner_0-1662619015863.png

 

 

The new and far better way: Just use an Arcade element! With this element, you can return HTML code which will be interpreted by the popup.

JohannesLindner_1-1662619126139.png

 

var areas =FeatureSetByName($map,"Neighborhood Council Districts (Tacoma)");
var Onefifty = Buffer($Feature, -150, 'feet')
var countp = Intersects(areas,Onefifty);

var result = "";
for (var item in countp){
    var name = item["Neighborhood"];
    var url = item["URL"]
    result += `<a href="${url}" target="_blank">${name}</a><br/>`
}

return { 
	type : 'text', 
	text : result
}

 


Have a great day!
Johannes
John_Shell
New Contributor III

Hi Johannes,

Thank you so very much! I love seeing this work. I really want to dive deeper into Arcade and now I can learn more about Arcade elements. It all makes sense now because I had been seeing other examples of people using Html code in their Arcade code. Now I can finish up this little project and on to my next project. I hope you have a fantastic day. You have definitely made a new friend for life.

Thank you,

John

0 Kudos
DaveSivertsenz
New Contributor II

Thanks for the helpful tips! The link to the map requires credentials, and is not accessible for most of the community.

0 Kudos
PedroSoares1
New Contributor II

Hi, sorry I could not be of much help, as I have been away. I am glad you have the problem solved.

cheers, good luck on your 'exploration'.

Pedro

0 Kudos