Why error 'dynamicLayers is not enabled on this MapService' ?

1318
3
Jump to solution
09-20-2017 06:15 PM
RolandoFlorez
New Contributor III

I'm getting this error when I try to classify a field like this example:

ArcGIS API for JavaScript Sandbox 

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

When publishing a service, there's the option to enable dynamic layers.

Determining which layers will appear in a map, layer symbology, layer order and position, labeling, and more, can be achieved on the server through the use of dynamic layers. In this way, dynamic layers can increase the amount of interaction that users are able to have with your maps.

You can check whether a service has this enabled with the property supportsDynamicLayers

var layer = new ArcGISDynamicMapServiceLayer("http://sampleserver5.arcgisonline.com/ArcGIS/rest/services/Energy/Geology/MapServer");  
layer.on("load", function(){  
  console.log(layer.supportsDynamicLayers);  
});  
map.addLayer(layer);  

View solution in original post

3 Replies
KenBuja
MVP Esteemed Contributor

When publishing a service, there's the option to enable dynamic layers.

Determining which layers will appear in a map, layer symbology, layer order and position, labeling, and more, can be achieved on the server through the use of dynamic layers. In this way, dynamic layers can increase the amount of interaction that users are able to have with your maps.

You can check whether a service has this enabled with the property supportsDynamicLayers

var layer = new ArcGISDynamicMapServiceLayer("http://sampleserver5.arcgisonline.com/ArcGIS/rest/services/Energy/Geology/MapServer");  
layer.on("load", function(){  
  console.log(layer.supportsDynamicLayers);  
});  
map.addLayer(layer);  
RolandoFlorez
New Contributor III

Hey Ken Buja, that was really helpful. That tip was very interesting.
But now, I have one more question ... A little bit far from this thread... Look: I have a widget that allow classify by fields and depending It changes layer visualization. So, this widget was developed with JS API version 3.17, when I put that widget in latest WAB (latest WAB manages JS API version 3.21), this widget does not work. Not clasifies satisfactorily.
My solution was replace the apiVersion value by 3.17 and then it worked.
The cuestion is: Why this widget not work correctly on 3.21 version, but 3.17 version yes?

0 Kudos
KenBuja
MVP Esteemed Contributor

I would suggest that you post this as a new question to get more visibility.

Have you examine the console to see if any errors are being generated? There might be a chance that one of the methods or properties on a class you're using was changed from v3.17. You should go through the What's New archive to see if any of the enhancements and updates affect your code.