JavaScript API - ArcGISDynamicMapServiceLayer SubLayer Scale Dependency Visibility

3751
12
07-16-2014 10:19 AM
BrandonColeman
New Contributor III

Background:

I am building a JavaScript web app using ESRI's JavaScript API v3.8, and our ArcGIS Server v9.3.1. I have layers I am rendering using the ArcGISDynamicMapServiceLayer, and I have been trying to find a way to access scale dependency visibility and have only been able to access the defaultVisibility.

Not Preferred Solution:

Using FeatureLayer for each layer allows me to check the MinScale against the map's current scale to determine whether the layer can be visible at that scale. I am trying to find a way to do this comparison using an ArcGISDynamicMapServiceLayer since it renders symbology based off of my map template or MSD file.

I would prefer to avoid setting up a dozen or so layers using FeatureLayer because I have to render each layer's symbology individually, since I am using ArcGIS Server v9.3.1, and it does not render it for me like 10.x+. This becomes tedious when I have a dozen or so layers each with a few class divisions.

Goal

I am using checkboxes for layer visibility, and if the layer isn't visible at the current scale, I am disabling and clearing the checkbox. I am using this as a way to tell the user that the layer isn't visible at this scale. A disabled control should be easier to understand than having a 'checked' checkbox and no layer showing up.

Anyone run into a similar situation? I am just trying to avoid coding in the symbology for all the layers as FeatureLayers.

Thanks!

0 Kudos
12 Replies
JeffPace
MVP Alum

When i do that on a 10.2.2 server i get

{"id":0,"name":"Interstates and Highways","parentLayerId":-1,"defaultVisibility":true,"subLayerIds":null,"minScale":0,"maxScale":0}

{"id":1,"name":"Major Road","parentLayerId":-1,"defaultVisibility":true,"subLayerIds":null,"minScale":200000,"maxScale":0}

{"id":2,"name":"Residential Street","parentLayerId":-1,"defaultVisibility":true,"subLayerIds":null,"minScale":80000,"maxScale":0}

{"id":3,"name":"Railroad","parentLayerId":-1,"defaultVisibility":true,"subLayerIds":null,"minScale":0,"maxScale":0}

for example

0 Kudos
BrandonColeman
New Contributor III

Ok, I am pretty sure then that it is me using the 9.3.1 server.  I guess for some reason it doesn't provide that information to a Dynamic Layer.  I get all the info you get except the scale information.

It is kind of weird that the server would restrict it because if I break up the layers individually and use FeatureLayer, the data comes along.

My list keep growing as to reasons to upgrade to a newer version of server.

0 Kudos
JeffPace
MVP Alum

Sorry I couldnt give you an easier answer.  But yes, seems like the upgrade would be helpful.

0 Kudos