Have one string for multiple instersected attributes from the same location in a popup via Arcade element

1178
12
Jump to solution
08-30-2023 12:45 PM
Ed_
by MVP Regular Contributor
MVP Regular Contributor

So I am trying to pull attributes from an intersected layer in a single popup. In certain popups however, there are for example 3 layers that overlay one another in the same location. Basically 3 address points thus 3 addresses as shown in the screenshot below.

Now is there a way I can have the Address: string to appear only once?
Also is it possible to adding numbering to the addresses (if more than 1 address is present) as shown in the desired output?

@KenBuja please when you have the time, can you have a look at it? Thank you 🙂

Current output (please ignore the blue color that's just due to the mouse selection):

SaadullahBaloch_0-1693424450957.png

Desired output:

Property Summary

Address: 
1) 3452 W ESFIE ST 90026
                  2) 3450 W EFIE ST 90026 
                  3) 3448 W EFIE ST 90026

Code:

 

 

 

// Create a variable that is the FeatureSet of intersecting feature attributes
var Address = FeatureSetByName($map, "ADDRESS")

var intersectLayer = Intersects(Address, $feature)

// This variable will be used multiple times in the code
var popup = '<h3>Property Summary</h3>';

for (var f in intersectLayer){

 popup += `<b>Address:</b> ${f.FullAddress} <br><br>

 `

}

// Now bring in the attributes from the next intersected layer

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

 

 

 

 

Question | Analyze | Visualize
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

Here's one way to do that. Unfortunately, the Arcade element strips out leading spaces, so everything gets left justified.

var Address = FeatureSetByName($map, "ADDRESS");
var intersectLayer = Intersects(Address, $feature);
var popup = '<h3>Property Summary</h3><b>Addresses:</b>';
var counter = 1;
for (var f in intersectLayer){
  popup += `${counter}) ${f.FullAddress}<br>`;
  counter++;
}

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

View solution in original post

12 Replies
KenBuja
MVP Esteemed Contributor

Here's one way to do that. Unfortunately, the Arcade element strips out leading spaces, so everything gets left justified.

var Address = FeatureSetByName($map, "ADDRESS");
var intersectLayer = Intersects(Address, $feature);
var popup = '<h3>Property Summary</h3><b>Addresses:</b>';
var counter = 1;
for (var f in intersectLayer){
  popup += `${counter}) ${f.FullAddress}<br>`;
  counter++;
}

return { 
  type : 'text', 
  text : popup
}
Ed_
by MVP Regular Contributor
MVP Regular Contributor

Awesome, thank you so much Ken 🙂

Question | Analyze | Visualize
0 Kudos
KenBuja
MVP Esteemed Contributor

Wait, I was incorrect about stripping leading spaces. The only way I was able to add leading spaces is using "&nbsp" for each space

popup += `&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp${counter}) ${f.FullAddress}<br>`;

 

Ed_
by MVP Regular Contributor
MVP Regular Contributor

Awesome thank you so much for the update Ken 🙂

Question | Analyze | Visualize
0 Kudos
Ed_
by MVP Regular Contributor
MVP Regular Contributor

Hi @KenBuja  Happy Friday,

Hope all is well; So when I add Address next to counter, the code also outputs it multiple times as in the screenshot below. Is there a way to have the Address string to appear only once even if there are more than one address?

Current code:

// Create a variable that is the FeatureSet of intersecting feature attributes
var Parcels = FeatureSetByname($map,"PARCEL")

// Create a new variable for address layer, this layer also intersects the parcel layer
var address = FeatureSetByname($map,"ADDRESS")

var intersectLayer = Intersects(address,$feature)

// First heading
var popup = '<h3>Property Summary</h3>';

var counter = 1;


for (var f in intersectLayer){
popup += `<b>Address:</b>&nbsp;&nbsp;&nbsp;&nbsp;${counter}) ${f.FullAddress} <br>`;

counter++;

}



popup += `<b>PIN:</b> ${$feature.PIN} <br><br>

<b>Tract#:</b> ${$feature.TRACT} <br><br>

<b>Block:</b> ${$feature.BLOCK} <br><br>

<b>ARB:</b> ${$feature.ARB} <br> <br>

<b>BPP:</b> ${$feature.BPP} <br> <br>

<b>LOT#:</b> ${$feature.LOT} <br> <br>

`

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

 

Current output:

SaadullahBaloch_0-1693609892109.png

 

Question | Analyze | Visualize
0 Kudos
KenBuja
MVP Esteemed Contributor

Change your code to this

 

popup += `<b>Address:</b><br>`;
for (var f in intersectLayer){
  popup += `&nbsp;&nbsp;&nbsp;&nbsp;${counter}) ${f.FullAddress} <br>`;
  counter++;
}

 

Ed_
by MVP Regular Contributor
MVP Regular Contributor

Happy Monday Ken.

Ah yes, this way it becomes a subheading :).

Question | Analyze | Visualize
0 Kudos
Ed_
by MVP Regular Contributor
MVP Regular Contributor

Hi @KenBuja 

I have a question please, is it possible to show the counter_value) to show only if there are more than two addresses?

Let's say there's only one address associated with a feature then the output would look something like this:

Address:
Some_Street_Address

However if a feature has two or more addresses then the output would look like this:

Address:
1) Some_Street_Address1
2) Some_Street_Address2
3) Some_Street_Address3
 

Question | Analyze | Visualize
0 Kudos
KenBuja
MVP Esteemed Contributor

You just have to put in a if statement to check whether there is more than one address.

popup += `<b>Address:</b><br>`;
if (Count(intersectLayer) == 1) {
  popup += `&nbsp;&nbsp;&nbsp;&nbsp;${First(intersectLayer).FullAddress} <br>`;
} else {
  var counter = 1;
  for (var f in intersectLayer){
    popup += `&nbsp;&nbsp;&nbsp;&nbsp;${counter}) ${f.FullAddress} <br>`;
    counter++;
  }
}