-1

I want to get existing layers from map and toggle on the visibility of the layers. The map has multiple services. I have the rest url for the service or the layer. And able to access the layer by using let fLayer = new FeatureLayer(url,....).

But when I tried on set visibility by using

fLayer.setVisibility(true) or fLayer.show()

didn't work for me.

I have the information on the required layer names or ids in the respective services and the service urls.

Is there any possibility to get a layer from map using the service url and the layer name/id in that service? Please suggest.

4
  • I suggest you try remove it from the map and re-add it when needed.
    – NettaB
    Commented Oct 5, 2019 at 21:01
  • But I think, to remove also I should pass layer information to map. I want to know how to get required layer from map in the above condition.
    – Venkat
    Commented Oct 6, 2019 at 1:48
  • can you share your code so we can help fixing it ?
    – LMokrane
    Commented Oct 14, 2019 at 10:41
  • Hi LMokrane, I got the solution and the same posted below
    – Venkat
    Commented Oct 16, 2019 at 5:56

1 Answer 1

0

I got the solution by doing similarly as in below link: https://community.esri.com/thread/27093

I need to get the map service as dynamic layer from map, set the visibility of that dynamic layer and send the array of ids of the required layers inside it for setVisibleLayers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.