stevel

Count-dependent rendering? Switch layer on/off depending on number of features

Discussion created by stevel on Feb 10, 2011
Latest reply on Feb 11, 2011 by hzhu
I have a set of multiple census layers, where the largest scale layer is very detailed over heavily populated areas, and quite coarse over remote areas.

I need to display the detailed layer when it makes sense to do so - which is not necessarily at the same scale across the entire map.

These screenshots illustrate the problem. At a scale of 1:500k the layer should display in rural areas:



But in urban areas, the layer shouldn't display until about 1:100k:



Using the JavaScript API and REST layers, is there any way to count the features in the current map extent, and turn the layer off/on accordinly? Eg, if there are fewer than 50 polygons, show the detailed layer, otherwise show the coarse layer.

Thanks,
Steve

Outcomes