Issue retrieving feature layer

100
3
07-31-2022 11:22 PM
utility9213
New Contributor III

Hello everyone, I am currently facing some issues retrieving my Feature Layer from the server directory. I am currently using ArcGIS API for JavaScript 3.41.

I have tried the following code however, there are some issues in retrieving the information I need. For eg. there are a few missing properties such as the id, info template, _fields within the layer itself.

Below are the 2 methods I have tried I am able to retrieve the layers however the properties are still undefined or empty. Am I missing any steps?

const layer = new FeatureLayer({ "sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0" });

 var flayer = new FeatureLayer({
         portalItem: {
         id: item._id
     }
 });

 

3 Replies
TimDietz
New Contributor

How about posting the rest of your code?  Maybe set it up in CodePen?

0 Kudos
utility9213
New Contributor III

Sorry.. the project is classified, but thanks for the reply..

0 Kudos
ReneRubalcava
Frequent Contributor II

It looks like you are trying to use 4x syntax in a 3x app. The FeatureLayer API in 3x is slightly different. You can just pass the URL.

https://developers.arcgis.com/javascript/3/jsapi/featurelayer-amd.html#featurelayer1

If you have the itemId, you can get the item and get the URL off of that

https://developers.arcgis.com/javascript/3/jsapi/esri.arcgis.utils-amd.html#getitem

0 Kudos