Hi,
I am creating an application with arcgis js 4.8 api. I bring in a WebMap into this application, which has a MapImage Layer. This MapImage Layer has multiple sublayers. I need to know the fields that exist in these sublayers, and I also need to know the type of each field (number, string... etc). The sublayer interface is here: Sublayer | API Reference | ArcGIS API for JavaScript 4.9. I can use the "popupTemplate" in the sublayer and then go into the fieldInfos property of that to get the names of the fields, however that does not have the type information for each field. Does anyone have any idea how to get the type information for each field of a sublayer?
Thanks
Solved! Go to Solution.
Cameron,
Full field info data is not available from the Sublayer object you will have to get the sublayer url and make an esriRequest to the sublayer to get the field data.
esriRequest(layer.findSublayerById(0).url, {
responseType: "json",
query: "f=json"
}).then(function(response){
// The requested data
var lyrJson = response.data;
console.log(lyrJson.fields);
});
Cameron,
Full field info data is not available from the Sublayer object you will have to get the sublayer url and make an esriRequest to the sublayer to get the field data.
esriRequest(layer.findSublayerById(0).url, {
responseType: "json",
query: "f=json"
}).then(function(response){
// The requested data
var lyrJson = response.data;
console.log(lyrJson.fields);
});
Understood. Thanks a lot Robert!
Hi at all.
Since API version 4.15 you can access the field property auf a sublayer. For details see Sublayer | ArcGIS API for JavaScript 4.16 . Just call the function "load" of the sublayer. After that you can access all fields.
Best regards
Martin