Select to view content in your preferred language

imageparameters.layerDefs does not work with 10.5

12827
44
Jump to solution
01-10-2017 10:14 AM
DuarteCarreira
Frequent Contributor

It seems REST API in 10.5 deprecated simple sintax on layerDefs:

ArcGIS REST API 

Simple syntax is not supported as an expected value for layerDefs parameter starting 10.5.

This is pretty hidden in the documentation by the way...

As a side effect, it seems imageparameter.layerDefinitions no longer works since it still translates requests to the simple sintax:

ImageParameters | API Reference | ArcGIS API for JavaScript 3.19 

In our server we get an error when debugging http requests on the browser's console:

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

Our code is pretty simple and worked last week against a 10.3 server.

Can anyone reproduce and confirm this?

EDIT: Just to add that the simplest sample from esri does not work against a 10.5 server:

Layer definitions on a dynamic map service | ArcGIS API for JavaScript 3.19 

It seems a bug to me... I wish I'm proven wrong...

Thanks.

44 Replies
JosephElfelt1
Regular Contributor

Glad I found this thread since it indicates the problem I am having is not of my own making. 

 

My unfortunate observation is that in the 10.41 REST API if you (1) use a layerDefs parameter ***with either JSON or non-JSON syntax*** and you (2) also use a dynamicLayers parameter, then your layerDefs parameter is ignored

 

I have developed a Google map viewer called Gmap4 that uses the ESRI REST API to display user-specified MapServer layers. 

 

The following map links use layer 9 from
https://services.nationalmap.gov/arcgis/rest/services/govunits/MapServer and also use a layerDefs parameter to display an outline map of just the congressional districts just in Washington State. The basemap tiles are all white. 

https://mappingsupport.com/p/gmap4.php?ll=46.822190,-120.490967&z=6&t=Congressional_district&rest=ht...

 

Since the layer I am displaying supports dynamic layers, I wish to change the styling of how the layer data appears on the map.  If I take the exact same map and add a dynamicLayers parameter, then (1) the appearance of layer 9 is correctly changed according to my dynamicLayers parameter, but (2) all congressional districts for the USA now appear on the map. In other words, the layerDefs parameter requesting only data for Washington state is ignored. I tried using non-JSON syntax for layerDefs and got the same result. 

https://mappingsupport.com/p/gmap4.php?ll=46.822190,-120.490967&z=6&t=Congressional_district&rest=ht...

 

I suspect that I am SOL and will simply have to wait for the server admin to change to a different version of ArcGIS that hopefully does not have this bug.

 

Joseph

0 Kudos
DuarteCarreira
Frequent Contributor

Joseph this is a different, unrelated problem, and I would suggest opening a new thread.

Anyway, you have to add a definitionExpression to your dynamicLayer 9. For instance:

https://mappingsupport.com/p/gmap4.php?ll=46.822190,-120.490967&z=6&t=Congressional_district&rest=ht...

That works.

0 Kudos
JosephElfelt1
Regular Contributor

@Duarte - Thanks for setting me straight.

Yup, I missed definitionExpression in the REST documentation but I see it now.  Works fine.

0 Kudos
DuarteCarreira
Frequent Contributor

@Joseph, just re-read my answer... I'm sorry if I came across less polite... I wrote that in a hurry and it's not my native language... just glad I could help out.

0 Kudos
JosephElfelt1
Regular Contributor

No worries!

I am thankful that you took the time to point out my mistake.

This is obviously the first time I have tried to wrap my brain around dynamic layers.

0 Kudos
GreggRoemhildt1
Deactivated User

Just got word from support this is fixed in version 3.20:

> The current status of the bug is "Implemented" and it is being addressed in JavaScript API version 3.20. As of now, we do not have the information when the next version will be released.

RobertScheitlin__GISP
MVP Emeritus

Gregg,

  3.19 was released @ 21 Dec 2016 and the API is on a 3 month release cycle so you can expect 3.20 to be around March. 

0 Kudos
DuarteCarreira
Frequent Contributor

So no patch? Really? So 10.5 is a dud release for 3 months? So... maintenance and support gets us on the bug list and a recommendation of "do not install"... I'm out of words...

0 Kudos
GreggRoemhildt1
Deactivated User

Just a side note and potential workaround:

While dynamic layers definition queries are not working, feature layer queries still are working so if you set up your feature layer to point to the dynamic mapserver url and add the layer id to the end, you can provide a where clause to the feature layer.

new FeatureLayer('/arcgis/rest/services/myservice/MapServer/0', {
    definitionExpression: 'myField = \'value\'';
});
0 Kudos
DuarteCarreira
Frequent Contributor

Hi Gregg. This works but implies a huge change to all logic in our applications. Changing from dynamicservices to featurelayers is a full rewrite of each app.

0 Kudos