Select to view content in your preferred language

Setting Scale Dependencies for Operational Layers

2075
5
03-20-2012 02:24 PM
PaulFerro1
Deactivated User
I want user's to be able to turn on/off layers at all scales, but then want all layers to turn on when zoomed in at a larger scale. say 18,056 or larger.

Is this possible to set for <layers> in the config.xml similar to LODS?
Tags (2)
0 Kudos
5 Replies
JonFisher
Emerging Contributor
Typically scale dependency is set in the mxd that the map service is based on, but it sounds like you're looking to do something a little different. Rather than having the data off at small scales and then turn on at large scales, you want to let the user turn it off or on at small scales, but force it to always be visible at large scales? I don't know of any way to do that without custom code. It sounds like you don't want the data to be scale dependent (available to turn on or off at some scales, and unavailable at other scales), but you want to turn certain layers on (no matter what) at certain scales. Am I understanding your problem correctly? If not, there may well be a couple of viable solutions.
0 Kudos
PaulFerro1
Deactivated User
jrfishe1
your assessment is exactly correct.  I figured it could be hard coded, but if possibly I want to deploy the code using the flexviewer. 

The workflow I have in mind is that user performs an address search, and then zooms into a scale of 18, 056 or larger and all the layers turn on.  But at scales smaller than 18, 056 the user would be able to turn on/off layers as they wish.
0 Kudos
JonFisher
Emerging Contributor
jrfishe1
your assessment is exactly correct.  I figured it could be hard coded, but if possibly I want to deploy the code using the flexviewer. 

The workflow I have in mind is that user performs an address search, and then zooms into a scale of 18, 056 or larger and all the layers turn on.  But at scales smaller than 18, 056 the user would be able to turn on/off layers as they wish.


Unfortunately none of the built-in options support that readily. The "displaylevels" attribute in the layer tag lets you turn a tiled or bing layer on at certain scale levels, but if you set that it will be invisible at the scale levels you don't specify.

If you really wanted to do it without code, here's how I'd go about doing it (I'm assuming you're using dynamic services, it would be a bit different for cached / tiled):
Make two copies of the mxd that has all the layers you want to behave in this way. Set scale dependence on one of the mxds so that the layers all disappear at the scales where you want the user to choose visibility, and that they appear where you want them to always be visible. The other mxd should be identical but have NO scale dependency. Make separate map services out of the two mxds. Hide the scale-dependent map service from the table of contents using <excludelayer> tag in the layer list or TOC widget.

The end result: you will have one map service show up in the table of contents. At small scales, the scale-dependent service (which is not in the TOC) is always invisible, and the other one will be on or off as the user chooses. At large scales, the scale-dependent service will always be visible, and if the user has checked the box to make it visible then it will actually load twice (on top of itself, so it will look identical and just be a bit slower). If the user has unchecked the box the layers will load once, and they may be confused why they didn't go away, but it meets your needs.

That's the only way I can think to do this without writing new code. It's a bit awkward, but functional.
0 Kudos
PaulFerro1
Deactivated User
Brilliant, why didn't I think of that?

I am a beginner at ActionScript, do you know how long it would take to code it?

Thanks for the help.
0 Kudos
JonFisher
Emerging Contributor
Well, the process I suggested would require no actionscript. I'm not sure how long it would take because I haven't done that much beyond extending and tweaking the flex viewer myself. It seems conceptually simple but I'm not sure to what degree the core components will try to override what you want to do.
0 Kudos