Is it possible to extract field Type information in onEachFeature?

983
2
11-16-2014 02:07 AM
GreigMcArthur
New Contributor

I'm currently using an older (6months+) version of esri-leaflet and previous I modified the onEachFeature function to be able to find the related L.esri.featureLayer for the layer. 

 

With this I could then access the field metadata through featureLayer.fields

           
The reason was for simple type detection and formatting for display in popup - i.e. detect the esriFieldTypeOID field and ignore it, or detect a date field and format the output accordingly etc.

 

I don't see an equivalent of the 'fields' array in the current FeatureLayer class - is there somewhere else I can get this metadata for a layer?

Tags (2)
0 Kudos
2 Replies
PatrickArlt1
Esri Contributor

Yes each layer has a built in layer.metadata() method to get the metadata for the layer. It accepts a callback function which will be executed with error and metadata which will contain your field information.

Getting service metadata | Esri Leaflet

In this example the metadata in the callback function should contain all your field information.

GreigMcArthur
New Contributor

That did it thanks- don't know how I missed that...very much appreciated!

0 Kudos