Something really strange is happening and I do not know why. When I create a new MapImageLayer and call for two sublayers whereas the visible value for both sublayers is 'true' I get an error.
RAILLAYER = new MapImageLayer({
url: "https://rave1:6443/arcgis/rest/services/RAIL/MapServer", sublayers: [
{id: 0,
visible: true,
title: "Railway Station"},
{id: 20,
visible: true,
title: "Railway"}
]
});
When there is one visible value as true (the other false), the sublayer displays.
RAILLAYER = new MapImageLayer({
url: "https://rave1:6443/arcgis/rest/services/RAIL/MapServer", sublayers: [{id: 0,
visible: true,
title: "Railway Station"},
{id: 20,
visible: false,
title: "Railway"}
]
});
The weird thing is that I tried using the sample layer from esri
http://sampleserver6.arcgisonline.com/arcgis/rest/services/911CallsHotspot/MapServer
and it works perfectly when both sublayers visible value are defined as true.
So I just want to figure out what could be the cause of this issue. By the way I am using arcgis javascript 4.10
Bobo,
Try adding the sublayers in descending order:
RAILLAYER = new MapImageLayer({
url: "https://rave1:6443/arcgis/rest/services/RAIL/MapServer",
sublayers: [{
id: 20,
visible: true,
title: "Railway"
},{
id: 0,
visible: true,
title: "Railway Station"
}]
});
Robert, you are an arcgis wiz. Thank you, it worked.
Could you explain to me why it works in descending order but not in ascending order.
Bobo,
This is just a known feature with sublayers that is not documented. Don't forget to mark the question as answered.
Before I mark as answered, something strange is still happening.
this works perfectly.
{id: 16,
visible: true,
title: "Highway"},
{id: 10,
visible: true,
title: "Sand Dune"},
{id: 8,
visible: true,
title: "Dams"},
{id: 7,
visible: true,
title: "Rivers"},
{id: 5,
visible: true,
title: "DWAF Water Scheme"},
{id: 4,
visible: true,
title: "Prison"},
{id: 3,
visible: true,
title: "School"},
{id: 2,
visible: true,
title: "Police Station"},
{id: 1,
visible: true,
title: "Health Facility"}
But when my code is like this
{id: 11,
visible: true,
title: "Vegetation"},
{id: 10,
visible: true,
title: "Sand Dune"},
{id: 8,
visible: true,
title: "Dams"},
{id: 7,
visible: true,
title: "Rivers"},
{id: 5,
visible: true,
title: "DWAF Water Scheme"},
{id: 4,
visible: true,
title: "Prison"},
{id: 3,
visible: true,
title: "School"},
{id: 2,
visible: true,
title: "Police Station"},
{id: 1,
visible: true,
title: "Health Facility"}
The same error i received as last time still occurs. Its kind of selective even if it is in descending order.
Bobo,
What is layer 11? is it an actual layer or a group layer? Are you sure the id 11 is your Vegetation layer?
It is the actual layer.
Sorry to say this might be a bug then.