Select to view content in your preferred language

Legend - Keep all symbology on and not turn off depending on scale range

3561
6
Jump to solution
06-28-2011 06:44 AM
AndyBurns
Regular Contributor
Hi

I have set scale ranges on my dynamic service and the legend is behaving as expected (legend removes symbology for data not available at that scale range)

Is there anyway to make it just display the symbology all the time and not turn on/off depending on scale?

I have followed this sample

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm

thanks
0 Kudos
1 Solution

Accepted Solutions
HemingZhu
Frequent Contributor
Hi

I have set scale ranges on my dynamic service and the legend is behaving as expected (legend removes symbology for data not available at that scale range)

Is there anyway to make it just display the symbology all the time and not turn on/off depending on scale?

I have followed this sample

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm

thanks


Try this:
var legend = new esri.dijit.Legend({
  map:map,
  respectCurrentMapScale: false
},"legendDiv");

View solution in original post

6 Replies
HemingZhu
Frequent Contributor
Hi

I have set scale ranges on my dynamic service and the legend is behaving as expected (legend removes symbology for data not available at that scale range)

Is there anyway to make it just display the symbology all the time and not turn on/off depending on scale?

I have followed this sample

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm

thanks


Try this:
var legend = new esri.dijit.Legend({
  map:map,
  respectCurrentMapScale: false
},"legendDiv");
JssrRR
by
Frequent Contributor

Heming,

Will this work on, ArcGISTiledMapservice too? because I am having the same issue, I have a tiled map service, with a group layer that has three sublayers , when I add the URL for the map service, in my application,  it shows up fine and the legend that comes up is for the layer that is visible, but as I zoom in and out it does not update to show the legend for visible layer.

Thanks,

Saloni.

0 Kudos
JssrRR
by
Frequent Contributor

Heming,

It worked in my tile layer service too, thanks.

0 Kudos
AndyBurns
Regular Contributor
thanks very much!
0 Kudos
DavidHollema
Deactivated User
The respectCurrentMapScale property does not control legend item visibility when turning map layers on or off.  I want legend items to remain visible when I turn off layer visibility using .hide().  Regardless of respectCurrentMapScale value, the legend item disappears when I turn visibility off.  Is that by design?  That's not how I read the documentation for this property...

"Optional. When true the legend will update with every scale change and displays only the layers and sub layers that are visible in the current map scale. When false, the legend does not update on every scale change and all layers and sub layers will be displayed. The default value is true. "

Try this:
var legend = new esri.dijit.Legend({
  map:map,
  respectCurrentMapScale: false
},"legendDiv");
0 Kudos
EdSaunders
Regular Contributor
David, I'm not sure if the esri legend dijit can be forced not to refresh every time a layer is switched on or off.  What you could do is just use a REST call to the legend endpoint of the service and then parse the JSON in the browser.  This doesn't depend on layer visibility.

http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Petroleum/KGS_OilGasFields_Kansas/MapServ...
0 Kudos