I declare a mapimagelayer
const MPl = new MapImageLayer({
----
----
Then I created an array of sublayers that need to be visilbe.
I added the sublayers index in an array
thearr.push({
id: 1,
visible: true},
{
id: 3,
visible: true}
);
Then, I used:
MPl.sublayers = thearr;
but I got an error
When I used this script without using typescript i have no errors and it runs fine.
Solved! Go to Solution.
I'm not 100% positive, but I think that if you don't declare the sublayers in the MapImageLayer constructor, you need to use one of the Collection methods to define/add/modify the sublayers.
Collection methods:
sublayers property:
I'm not 100% positive, but I think that if you don't declare the sublayers in the MapImageLayer constructor, you need to use one of the Collection methods to define/add/modify the sublayers.
Collection methods:
sublayers property:
Thank you. Looking at the documentation, it seems that in JS 4.x is more work to define visible layers of a mapimagelayer. In JS 3.x we could just write this.
lyr.setVisibleLayers([1,2,3])
I assume there is no similar way of doing so in JS 4.x
In a collection like
MPl.sublayers.push(item)
where item or comma-separated list of items cannot be the sublayer id.
Yes, there is an implementation difference between 3x and 4x. I would highly recommend looking at some 4x samples to get a feel for the difference. These two might be useful: