Hello!
I'm working with JS version 4.10 with a server on version 10.61 and I'm having some issues using MapImageLayer.
I've made a small application with one MapImageLayer with three sublayers. If I have more then one of the sublayers visible it starts to output error messages. Having one or none sublayer visible works fine, but I need to have more than one sublayer visible.
The error I'm getting is:
service .../MapServer doesn't support dynamic layers, which is required to be able to change the sublayer's order, rendering, labeling or source
Is this not supported by the server (v. 10.61) or did I do something wrong implementing MapImageLayer maybe? A feature I can turn on?
var layer = { name: "Work orders", url: ".../MapServer", subLayers: [ { name: "Not planned", visible: false, searchDisplayField: "Title", searchFields: ["Title"], id: 0, popupTemplate: workOrderPopupTemplate }, { name: "Planned", visible: false, searchDisplayField: "Title", searchFields: ["Title"], id: 1, popupTemplate: workOrderPopupTemplate }, { name: "Finished", visible: false, searchDisplayField: "Title", searchFields: ["Title"], id: 2, popupTemplate: workOrderPopupTemplate } ] }; var mapImageLayer = new MapImageLayer({ url: layer.url, title: layer.name, sublayers: [] }); map.add(mapImageLayer); for (var i in layer.subLayers) { mapImageLayer.sublayers.add({ id: layer.subLayers[i].id, visible: layer.subLayers[i].visible, title: layer.subLayers[i].name, popupTemplate: layer.subLayers[i].popupTemplate }); };
Solved! Go to Solution.
Lars,
You should set sublayers like this (notice the descending order):
var layer = new MapImageLayer({
url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer",
sublayers: [
{
id: 2,
visible: false,
popupTemplate: workOrderPopupTemplate
},
{
id: 1,
visible: false,
popupTemplate: workOrderPopupTemplate
},
{
id: 0,
visible: false,
popupTemplate: workOrderPopupTemplate
}]
});
Lars,
You should set sublayers like this (notice the descending order):
var layer = new MapImageLayer({
url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer",
sublayers: [
{
id: 2,
visible: false,
popupTemplate: workOrderPopupTemplate
},
{
id: 1,
visible: false,
popupTemplate: workOrderPopupTemplate
},
{
id: 0,
visible: false,
popupTemplate: workOrderPopupTemplate
}]
});
Thanks Robert! I was not aware of this! 🙂