Can intersect be used within one service (in a web map) or do the endpoints have to be added individually?

1551
12
09-16-2021 11:35 AM
Labels (1)
AdamGebhart
Occasional Contributor III

Is it possible to set up an Arcade expression with the intersect function that references another layer within the same service as the features in which the expression is applied?  Or, do you have to add each endpoint within the service individually in order to make the expression work?

For example, I have a service with three layers: address points, food inspector zones, and watershed inspector zones.  If I add each of the endpoints individually, the following expression (in the address points) returns the desired value (from the food inspector zone layer):

AdamGebhart_0-1631816860005.png

However, if I add the whole service to my map and set up the same expression on the address points there it does NOT work.  I get this error:

AdamGebhart_1-1631817031312.png

Does it simply not work within a service?  Or do I have a wrong parameter?

 

0 Kudos
12 Replies
AdamGebhart
Occasional Contributor III

@XanderBakker 

 

Hi Xander.  Is there any chance you can answer my question above?  Can I set up an expression in my address points that includes the intersection function, and have that be based on one of the polygon features in the layers above it?  Note, all three items are published in one map service.  I can't get it to work this way but can when I add each endpoint individually... which isn't really feasible in the grand scheme of the web map and WAB app.

AdamGebhart_0-1643057903505.png

 

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi @AdamGebhart ,

So you have a group layer in your (classic 3.x) web map and the Arcade expression I assume you are configuring in the pop-up. Is that correct?

When you want to access data in the map, I would suggest using the expression builder. There are two easy ways of assessing the data in the map, one is using $map that is creating problems, but since the data has the same datastore, you could try and use $datastore and see if that works. In the interface you can click on the arrow pointing to the right (">") next to "$datastore" and navigate to the layers in the same datastore as your feature. 

XanderBakker_0-1643125697473.png

this will list the layers (rest endpoints in the same service) and select the ones you need for the expression:

XanderBakker_1-1643125732052.png

If you have any problems, let me know.

 

0 Kudos
AdamGebhart
Occasional Contributor III

Thanks @XanderBakker.  Unfortunately, I don't see the $datastore option.  All I am seeing are the fields within this specific dataset.  To clarify though, I am...

-Trying to use Intersects in a web map pop up for an address point layer, based on what inspector zone a point falls in.

-Building in the pop up expression builder.

-Said address points and inspector zones are present in the same AGS map service (not AGO feature layer) and the entire map service has been added to the web map.

 

AdamGebhart_0-1643128817321.png

I did try it where I replaced $map with $datastore (but no other changes) and that didn't work.  Do you have an idea of how that full expression should look?

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi @AdamGebhart ,

So the limitation might be in the way the service is added to the map. Would it be possible to have access to the map to have a look? You could share it with a group and invite me to that group using "xbakker.spx".

0 Kudos
AdamGebhart
Occasional Contributor III

Just sent the invite, thank you.  At the top of the map contents you'll see an address point layer and food and watershed inspector layers.  Each of those is an item within a larger map service (see said map service below them in the contents) and have been added as individual items to this map. 

I can get the expression to work when the individual instance of the address points is used, but not when attempting to do it purely in the map service list.

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi @AdamGebhart ,

 

Thanks for sharing the map. However, I don't seem to have access to the services, so I can't really do anything at the moment. I can have a look at some of the sample Enterprise/ArcGIS Server services to see if I can replicate the situation. What version do you have for your Enterprise implementation?

0 Kudos
AdamGebhart
Occasional Contributor III

Can you view this in a web map?

https://gis.johnsoncountyiowa.gov/arcgis/rest/services/PH_Inspect/MapServer

It's a different service, but the same three datasets I'm referencing in that map.

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi @AdamGebhart ,

I continued with a map service (group layer)  from a sample server and this is what I got:

  • You are completely right that when adding a map service to the map, it will not provide access to the different layers in the same service. 
  • I thought that maybe the using the FeatureSetByPortalItem could be used. However, the layer is not a portal item in my portal
  • To overcome this aspect I added a new item to my portal by referencing the map service. This provided the portal item ID that I need to access the other layers within the grouplayer

Below you can see the classic web map with a group layer (map service: https://sampleserver6.arcgisonline.com/arcgis/rest/services/Military/MapServer) and the pop-up on the polygon areas show information from the intersecting units:

XanderBakker_0-1643136450607.png

 

Here's the expression I used: 

var spx = Portal('https://utility-esri-co.maps.arcgis.com');
var mili = FeatureSetByPortalItem(spx, 'e5cfe3e339394ffb82270e3791a32b6a', 2);

var fsint = Intersects(mili, $feature);
var result = "";
if (Count(fsint)>0) {
    result = "Found " + Count(fsint) + " intersecting features:";
    for (var f in fsint) {
        result += TextFormatting.NewLine + " - " + f["SymbolName"];
    }
} else {
    result = "No intersection";
}

return result;

 

0 Kudos
XanderBakker
Esri Esteemed Contributor

... and just tried, but I don't have access to the rest service you provided. 

0 Kudos