Select to view content in your preferred language

{"error":{"code":400,"message":"Invalid 'layerDefs' is specified","details":[]}}

2114
8
01-31-2019 08:57 AM
NatashaManzuiga
Regular Contributor

Hi All, I have upgraded my ArcGIS Server to the version 10.6.

I'm using the API 3.26 and I don't know why the method setLayerDefinitions doesnt work anymore...it seems like is changed the synthax...

Someone had my same issue?
I saw that there was a bug with the version 10.5 BUG-000102051: The setLayerDefinitions() function against DynamicMa.. 
but this is the version 10.6..

Can someone help me?
Thanks,

Naty
8 Replies
RobertScheitlin__GISP
MVP Emeritus

Naty,

  Please provide a code snippet of how you are attempting to apply the layer definitions.

Here is an example of how it should look:

var layerDefinitions = [];
layerDefinitions[0] = "POPULATION > 5000000";
layerDefinitions[5] = "AREA > 100000";
dynamicMapServiceLayer.setLayerDefinitions(layerDefinitions);
0 Kudos
NatashaManzuiga
Regular Contributor

Hi Robert, I'm using LocalLayer Widget in my WAB Application.
The following code works perfectly with ArcGIS Server 10.3.
It seems link the URL that create the method setLayerDefinitions is not compatible with ArcGIS Server 10.6.
Maybe, it's different....and I should see which layers are visible....and apply only to them setLayerDefinitions.
Many thanks in advance,
Naty

var lLayer = new ArcGISDynamicMapServiceLayer(layer.url, lOptions);
var layerDefinitions = [];
for (var prop in definitionQueries) {
    layerDefinitions[prop] = definitionQueries[prop];
}

var parameterURLQuery_def = 'Id=100';

layerDefinitions[0] = parameterURLQuery_def;
layerDefinitions[1] = parameterURLQuery_def;
layerDefinitions[2] = parameterURLQuery_def;
layerDefinitions[3] = parameterURLQuery_def;
layerDefinitions[4] = parameterURLQuery_def;
layerDefinitions[5] = parameterURLQuery_def;
layerDefinitions[6] = parameterURLQuery_def;
layerDefinitions[7] = parameterURLQuery_def;
layerDefinitions[8] = parameterURLQuery_def;
lLayer.setLayerDefinitions(layerDefinitions,true);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Robert Scheitlin, GISP wrote:

Naty,

 

  Please provide a code snippet of how you are attempting to apply the layer definitions.

Here is an example of how it should look:

var layerDefinitions = [];
layerDefinitions[0] = "POPULATION > 5000000";
layerDefinitions[5] = "AREA > 100000";
dynamicMapServiceLayer.setLayerDefinitions(layerDefinitions);‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Naty,

  So each layer in the map service has a feature that has an "Id" field that is numeric with a value of 100?..

0 Kudos
NatashaManzuiga
Regular Contributor

Yes Robert,

Naty

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Naty,

   OK strange. What is this whole part about?

for (var prop in definitionQueries) {
    layerDefinitions[prop] = definitionQueries[prop];
}
0 Kudos
NatashaManzuiga
Regular Contributor

It’s of the LocalLayer widget..

I suppose that the syntax changed somehow.

I tried to modify the URL sent to export the map filtered by the setLayerDefinitions and it doesn’t work but it works on ArcGIS Server 10.3..

Thanks,

Naty

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Naty,

  comment out these lines and test again:

for (var prop in definitionQueries) {
    layerDefinitions[prop] = definitionQueries[prop];
}
0 Kudos
NatashaManzuiga
Regular Contributor

Hi Robert, I tried with comment out these lines....but nothing changed...

At least I better analyzed the URL prepared by the API..and I noticed that the problem is with the 10.6 version of ArcGIS.
I just can use setLayerDefinitions for the visible SubLayers.

so...I changed my code to:

var i;
var visiblelLayers =lLayer.visibleLayers;
for (i=0; i < visiblelLayers.length;i++){
layerDefinitions[visiblelLayers[i]]=urlParameter;
}

lyr.setLayerDefinitions(layerDefinitions,true);

so it's not true what they say here:

ArcGISDynamicMapServiceLayer-amd | API Reference | ArcGIS API for JavaScript

Definition expressions for layers that are currently not visible will be ignored by the server.

So the last thing I need now is that when I activate a Layer (in the LayerList widget) I don't have set a Layer Definition...and I should set it somehow before adding it...

Thanks,

Naty

0 Kudos