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):
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
}
Solved! Go to Solution.
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
}
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
}
Awesome, thank you so much Ken 🙂
Wait, I was incorrect about stripping leading spaces. The only way I was able to add leading spaces is using " " for each space
popup += `      ${counter}) ${f.FullAddress}<br>`;
Awesome thank you so much for the update Ken 🙂
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> ${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:
Change your code to this
popup += `<b>Address:</b><br>`;
for (var f in intersectLayer){
popup += ` ${counter}) ${f.FullAddress} <br>`;
counter++;
}
Happy Monday Ken.
Ah yes, this way it becomes a subheading :).
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
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 += ` ${First(intersectLayer).FullAddress} <br>`;
} else {
var counter = 1;
for (var f in intersectLayer){
popup += ` ${counter}) ${f.FullAddress} <br>`;
counter++;
}
}