tggagne

How to get all feature attributes into Javascript?

Discussion created by tggagne on Mar 18, 2014
How can I all a feature's attributes into Javascript? 

When we use {*} to indicate all attributes, the only info template we can use is ${*}, but that doesn't allow us to add any HTML.

The end goal is we need to get all a feature's attributes into some kind of string (json is fine) so we can do something with it.  In our case we need to persist it elsewhere.

In our page, we don't know which layers a user may select, or what feature they may click on, or even which attributes they'll be interested in.  Each layer has unique attributes for its features, so we need to use some kind of wildcard.

layerMap[layerObject.name] = new FeatureLayer(each, {
  mode: FeatureLayer.MODE_SNAPSHOT,
  outFields: ["*"],
  infoTemplate: new InfoTemplate(layerObject.name, "${*}") 
});


Adding anything to the InfoTemplate screws it up.  All we'll get is what we added, none of the key-value pairs.

Outcomes