Select to view content in your preferred language

Create a FeatureLayer with client-side graphics, attributes missing

1142
3
Jump to solution
06-20-2019 01:46 PM
XiaowenHuang
Emerging Contributor

I use the following sample to add a shapefile to FeatureLayer but attributes won't carry over.

ArcGIS API for JavaScript Sandbox 

Any idea how I can retain all attributes from shapefile?

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

You just need to specify the Feature Layers fields and outFields properties in that sample.

            var featureLayer = new FeatureLayer({
              popupTemplate: popupTemplate,
              objectIdField: "FID",
              source: graphics,
              outFields: ['*'],
              fields: layer.layerDefinition.fields
            });

View solution in original post

3 Replies
DavidWilson3
Regular Contributor

Hi Xiaowen,

Do you have screenshots or code you can share? Off the top of my head I would think that perhaps your shapefile is not a zip folder or your zip folder does not have all the necessary files in it to draw it with attributes.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

You just need to specify the Feature Layers fields and outFields properties in that sample.

            var featureLayer = new FeatureLayer({
              popupTemplate: popupTemplate,
              objectIdField: "FID",
              source: graphics,
              outFields: ['*'],
              fields: layer.layerDefinition.fields
            });
XiaowenHuang
Emerging Contributor

Thanks! adding "fields: layer.layerDefinition.fields" solved the issue.

0 Kudos