I'm trying to add a legend to my web map and it's proving very difficult. I've managed to get a legend to show up, but for some reason, it is split into three sections, and as Arcmap only labels high and low, the middle section is missing.
So, above we can see the properties of one of the raster layers in Arcmap. By default, only the high and low labels are populated, but I manually added a medium label and the TOC looked like the image at bottom left.
After publishing the GP service to my server, the REST services directory (http://myserver:6080/arcgis/rest/services/LFP/lfp01Setup/MapServer/legend) looks like the bottom middle image - the medium value is still there.
However, when I run a job using the javascript API and add a result map and legend to my web page, the medium value has gone. It looks like the high and low values have been recalculated too, so I guess the whole raster stretch has been recreated from scratch.
So, how do I get my result map to show the full color ramp?
cc ArcGIS for Server Web Developers GIS
Update:
This has been logged as two bugs, see http://support.esri.com for more details:
BUG-000092784 : Running a Geoprocessing service at Rest endpoint and publishing the result as a map service causes the Legend color ramp values to change.
BUG-000092783 : Running a Geoprocessing service using the javascript API and adding the result map and legend to the application causes the medium value of the legend to disappear.
Jon,
Can you use css to stretch your legend and see if it does not show all because it is compressed?
I'm not sure how you would do that - everything the legend widget does happens under the hood, you just tell it which element to place it in. Here's the page after the legend has been added:
But here is the page before you load it in the browser:
<div class="col-sm-3" id="bottom-legend">
<div id="bottom-legend-title">Legend</div>
<div class="blue-bar"></div>
<div class="white-bar"></div>
<div id="bottom-legend-actual"></div>
<div id="bottom-legend-footer"></div>
</div>
I tried interrogating the legend element in the developer console and when you burrow down into the legendResponse object, there is no label for the middle value:
Jon,
Is the legend dynamic?
I am having a hard time finding a service that has a color ramp to play with.
Is the legend dynamic?
No idea. All it says in the Javascript API is
The legend automatically updates if the visibility of a layer or sublayer changes.
The GP publishing help says
The symbology, labeling, transparency, and all other properties of the returned map are the same as the output layer in your current ArcMap session.
but this is not true as it is clearly recalculating the raster stretch rather than using what was in the original mxd.
I am having a hard time finding a service that has a color ramp to play with.
Yes, we're having a hard time finding anything to do with rasters. All the doc is full of information on feature classes, but there is very little on rasters.
Thanks Rickey, that sample looked great until I substituted my map service into the legend.
It must be something to do with the MapServer itself. I've compared the REST services directory for Ken's and my map service and they have different settings. In particular, Ken's has Single Fused Map Cache = true and contains Tile Info, and mine does not have a cache but does support dynamic layers. The legend I'm using is not the dynamic legend though.
I can't see any way to change the settings of my map service - it is just generated along with the GP service. You just check "View results with a map service" when publishing the GP result. See Publishing GP service settings.
BUMP
So, does anyone know why Ken Buja's legend and my legend display differently? Is there a way to alter the settings of a GP service result map so the medium value shows?