Select to view content in your preferred language

Select top feature layer

704
6
Jump to solution
11-15-2023 06:57 AM
ITApplications
New Contributor III
Hi all, I think this should be a simple query.
 
I have a map which has two feature layers, a points layer and a line layer.
 
I have ordered the layers so that the points layer sits above the line layer, see example below.
 
image1.png
 
My query/issue is, is that when I try to click on a point, it always selects the line layer first (despite graphically it being on top). I then have to cycle through the popup results for it to select the point and display its popup.
 
As you can see in the image below, it's selected my line layer despite me clicking on the point.
 
It displays the line layer popup firstIt displays the line layer popup first
I then have to cycle the popup for it to select and show the point
image3.png
 
I've tried rearranging the layers and have poured through the ESRI pages but I can't find anything that answers my query.
 
In these cases, if you click on the point, I would like it to either just select that point (and not the layer below it) or at least display the point popup first.
 
 
Hoping this is a simple solution.
0 Kudos
1 Solution

Accepted Solutions
JoelBennett
MVP Regular Contributor

The order of features displayed in the popup has produced no small amount of lively discussion.  The popup does not show features in layer order, but rather in order of how quickly results are retrieved from the layers.  Pretty much everything you'd ever want to know about it is in this thread, which although started back in 2014 continues to the present day.  Despite the discussion being in a different context (ArcGIS Online), it's the very same issue.

View solution in original post

6 Replies
KenBuja
MVP Esteemed Contributor

You can set the popupEnabled property to false for any layer you don't want the popup to appear.

     const streetLayer = new FeatureLayer({
        url: "https://services6.arcgis.com/Qptn479QktK11k72/arcgis/rest/services/Stsearch/FeatureServer",
        definitionExpression: ("Customer_N in ('HW: ERYC Highway Maintained','HW: ERYC Part Maintained')"),
        outFields: ["*"],
        title: "East Riding maintained road",
        renderer: stsRend,
        popupEnabled: false
     });
0 Kudos
ITApplications
New Contributor III

Hi Ken

 

Thanks for the quick response. How do I then get that popup to appear if I click directly on that layer, i.e. I want to log a new pothole issue?

I need the popup for the points (existing pothole issues) to appear if I click directly on them, but the popup for the street layer (log a new pothole) to appear if I click anywhere else (on the line layer).

I'd seen something about graphics drawing order on another post but not sure if that is the issue or how to implement it.

0 Kudos
KenBuja
MVP Esteemed Contributor

Could you use the same logic used in this post?

 

0 Kudos
JoelBennett
MVP Regular Contributor

The order of features displayed in the popup has produced no small amount of lively discussion.  The popup does not show features in layer order, but rather in order of how quickly results are retrieved from the layers.  Pretty much everything you'd ever want to know about it is in this thread, which although started back in 2014 continues to the present day.  Despite the discussion being in a different context (ArcGIS Online), it's the very same issue.

ITApplications
New Contributor III

Hi Joel

Wow, this is my exact query and yes agreed what a lively discussion! Seems sadly there is no sort order other than the fastest to load first wins. I did notice on my popups that before I added the url's to the point features they were loading first (before the line feature popup) and that was exactly what I wanted,

Sounds like no way to set the order (yet) so looks like my only option at the moment is to strip down my point feature popups to get them to win the race and load faster.

Thanks for your pointer on this.

0 Kudos
JoelBennett
MVP Regular Contributor

Looks like @LaurenBoyd has a Christmas present that's going to make a lot of people happy this year.  According to this page, the popup will display features in layer order starting in 4.29 (expected release in February 2024).

"The Popup and Features widgets now display features from multiple layers in the order they are displayed in the map. This means that the features of the topmost layer in the map will appear first, followed by the features of the next layer, and so on. In previous versions, the features were displayed in the order they were returned from the server."