I'm adding a Dynamic Map Service to an ArcGIS Server JavaScript API map, and I need to get hold of each component layer and its fields, so I can run a query.
See the sample ArcGIS Server services directory at http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/MapServer
If you open this URL in a browser you can see the list of available layers (0,1,2) and each layer's fields.
How can I retrieve the list of fields programatically, within a JavaScript function? The code snippet below shows how to retrieve the layer endpoints, but I can't see how to get to the fields.
(One option is to add the layers as Feature Layers, but I'd prefer to avoid this if possible).
var url = "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/MapServer/";
var dynLayer = new esri.layers.ArcGISDynamicMapServiceLayer(url);
map.addLayer(dynLayer);
dojo.connect(dynLayer, "onLoad", function() {
var infos = dynLayer.layerInfos;
for (var i = 0; i <= infos.length - 1; i++) {
var layerId = infos[i].id;
var restEndPoint = url + layerId;
//restEndPoint is the layer's URL - how can I retrieve its fields?
}
});
Thanks, Steve (cross-posted to the ArcGIS Server forum)