I am hoping to use createQuery() queryFeatures() methods on a sublayer of a MapImageLayer. The documentation on SubLayers seems to suggest this would be possible. The code below mirrors an example from the following link: Query features from a FeatureLayer | ArcGIS API for JavaScript 4.16. the mapLayer is a MapImageLayer with one sublayer. I am hoping to load the values from the POSTCODE field into a dropdown menu, stored in the variable zipCodeSelect. mapLayer
.when(function (){
var subLayer = mapLayer.findSubLayerById(0);
return subLayer.when(function () {
var query = subLayer.createQuery();
return subLayer.queryFeatures(query);
})
})
.then(getZipCodes)
.then(addToZipCodes);
function getZipCodes(response) {
var features = response.features;
var zipCodes = features.map(function(feature){
return feature.attributes.POSTCODE;
});
return zipCodes
}
function addToZipCodes(zipCodes) {
zipCodes.sort();
zipCodes.forEach(function (code) {
var option = document.createElement("option");
option.text = code;
zipCodeSelect.add(option);
});
}
return newValues
});