Select to view content in your preferred language

How to determine whether a layer is on but outside the scale range

1177
6
04-11-2012 11:04 PM
StephenLead
Honored Contributor
Is there a way to determine whether a layer is switched on, but is not currently shown due to the scale threshold?

See the attached file for an example. When the map first loads, the counties layer is "on" but is not shown due to the map scale. Zoom in a level and and the counties appear.

How can I determine this programmatically? featureLayer.visible returns "true" at all scales. featureLayer.onVisibilityChange doesn't fire when the scale threshold is crossed.

The workaround is to check the current map scale (by finding the LOD and figuring out the corresponding scale?) and compare it to the layer's minScale and maxScale. This seems like a clumsy workaround - is it the only option?

Thanks,
Steve
0 Kudos
6 Replies
JeffPace
MVP Alum
Is there a way to determine whether a layer is switched on, but is not currently shown due to the scale threshold?

See the attached file for an example. When the map first loads, the counties layer is "on" but is not shown due to the map scale. Zoom in a level and and the counties appear.

How can I determine this programmatically? featureLayer.visible returns "true" at all scales. featureLayer.onVisibilityChange doesn't fire when the scale threshold is crossed.

The workaround is to check the current map scale (by finding the LOD and figuring out the corresponding scale?) and compare it to the layer's minScale and maxScale. This seems like a clumsy workaround - is it the only option?

Thanks,
Steve


This clumsy workaround is the only one I could come up with as well, due to the exact limitation you listed. When i layer loads, i check the min/max of all the component layers of the service.  We had people complain about not being able to see greyed out text, so we color coded green for visibile, yellow for partially visible (some sublayers on, some off) and red for hidden due to scale dependencies.

http://www.mymanatee.org/gisapps/mapviewer/

You can see in our "Live Maps" TOC widget the color coded scale icons.  We also incorporated legend thumbnails.
0 Kudos
PaulBushore
Deactivated User
0 Kudos
JeffPace
MVP Alum
Paul yes getting the map scale you use that method, its getting the Layer (and sublayer) visibilities that is, well, difficult.

For example:

Current Map scale 1:10000

1 Dynamic Layer with 3 sublayers (a,b,c)
a - visible all the time
b - turns on at 1:15000
c - turns on at 1:5000

Most of us would prefer this displayed ArcMAP style where the group (1) indicates some layers arent drawing

so:

1 (symbolize some not drawing)
- a - (symbolize as visible)
- b - (symbolize as checked and visible, but would turn off if you zoom out)
- c - (symbolize as checked, but not visible due to scale)

unfortunately to get the info about the sublayers you need to make a separate query to the MapService to get the layer properties.  You also either need to store this info (per layer) and check it when the scale changes (onzoomin, onzoomout) or you need to make queries everytime.
0 Kudos
StephenLead
Honored Contributor
Would they be able to use the getscale method for the map?
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi_start.htm#jsapi/namespace_geometry.htm...


Cool, thanks for the tip. I wasn't aware of that. (strange that it's not just a property of the map, though)
0 Kudos
StephenLead
Honored Contributor
This clumsy workaround is the only one I could come up with as well, due to the exact limitation you listed.


Sounds like an enhancement request for Esri.

We'd need a boolean property for "will display at the current scale". This should apply to featureLayers and tiledMapServiceLayers, and for each layer of a dynamicMapServiceLayer.

Cheers,
Steve
0 Kudos
JeffPace
MVP Alum
Sounds like an enhancement request for Esri.

We'd need a boolean property for "will display at the current scale". This should apply to featureLayers and tiledMapServiceLayers, and for each layer of a dynamicMapServiceLayer.

Cheers,
Steve


I think its each layer of a tiled as well.  Need to know why its not showing in the tile!
0 Kudos