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!
I'm having a little trouble understanding the question. Based upon my understanding you wish to set the visibility of individual layers in a ArcGISDynamicMapServiceLayer to false if the current map scale is larger than a layer's minimum scale? Let me know if this is correct and I can proceed to solve the issue.
If you are trying to control the DynamicLayer you can set minscale and maxscale when you define it.
If you are trying to determine the scale visibility of the DynamicLayer, that is determined on each layer within it (the feature classes)
Those scale dependencies can be accessed through the layerInfos property
Nicholas Haney --> that is the general idea. I am trying to directly tie it to the checkboxes I am using. Have my checkboxes disabled if the layer can't be viewed at that scale or enabled and checked/not checked if it can be visible at that scale.
Jeff Pace --> That is what I thought. Below are the properties I am able to access through the layerInfo. I pulled this out through Chrome's dev tools. I know the property has to be there somewhere, but I cannot find it for anything. I looked at the documentation on layerInfos and the information should be there. I don't know if it would have something to do with my server being 9.3.1, which I have already seen is missing some of the nicer options in the more up-to-date versions.
i am surprised sublayerIds is null. Does this service only have one layer?
Can you show the rest url?
And i have to tell you this, but my guess is this will not work at 9.3.1
There are 6 layers in there. The URL is UTC_Viewers/Louisville_Pilot (MapServer).
When I go into the individual layers there, it will show the minScale/maxScale, but they probably aren't exposed to the ArcGISDynamicMapServiceLayer in 9.3.1.
ahhh.... get the layerInfo on the DynamicLayer (LouisvillePilot) not the sublayer (PilotBoundary).
When I get the layerInfo from the DynamicLayer, I get a collection of objects returned:
[
,
,
etc.etc.etc.
I still don't get the minScale property though. I have been drilling down the properties through Chrome Dev Tools, but I still haven't found that yet.
instead of just sniffing, can you
console.dir(layer.layerInfos);
Didn't know of that. I have been playing around in the interactive console window though on Chrome Dev Tools instead of coding it in though.
I will definitely keep the dir in mind though when I am debugging in code though. Thanks for that.