Select to view content in your preferred language

Features widget using FeatureLayer added to map

416
1
Jump to solution
07-06-2023 05:14 PM
LefterisKoumis
Regular Contributor II

I am trying to use the new Features widget to have the popup info posted on the side panel. 

There is an example at 

https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=widgets-features 

that it uses a featurelayer from the portal.

Below, I modified the above example by removing the webmap and added a feature layer. But I can't see the popup info if you click on a feature. What am I missing? Thank you.

https://codepen.io/lkoumis1/pen/BaGwrde?editors=1000 

 

0 Kudos
1 Solution

Accepted Solutions
LaurenBoyd
Esri Contributor

Hi @LefterisKoumis -

When you want to use the fetchFeatures method, the layers need to have an associated popupTemplate set. This is noted in the description of the method.

If you add a popup template to your feature layer, the features are fetched successfully: 

const featureLayer = new FeatureLayer({
    url:
   "https://gis.cnra.ca.gov/arcgis/rest/services/Boundaries/CCED_AccessType/MapServer/0",
    popupTemplate: {
        title: "Title",
        content: "This is the content."
    }
});

Hope this helps! 

Lauren

View solution in original post

0 Kudos
1 Reply
LaurenBoyd
Esri Contributor

Hi @LefterisKoumis -

When you want to use the fetchFeatures method, the layers need to have an associated popupTemplate set. This is noted in the description of the method.

If you add a popup template to your feature layer, the features are fetched successfully: 

const featureLayer = new FeatureLayer({
    url:
   "https://gis.cnra.ca.gov/arcgis/rest/services/Boundaries/CCED_AccessType/MapServer/0",
    popupTemplate: {
        title: "Title",
        content: "This is the content."
    }
});

Hope this helps! 

Lauren
0 Kudos