[OpenLayers-Users] Best way to get a legend over a map

Samuel Gilbert samuel.gilbert at ec.gc.ca
Wed May 15 11:08:27 PDT 2013


Hello,

I'm using OpenLayer to display forecasted air pollutant concentrations and 
rain from radar scans.  The layers I display are therefore color graduated.  I 
would like to add a color scale to the map to make the correspondence between 
the color and the forecasted concentration or rain intensity.  Since the 
application will be used in full-screen mode, I would like the legend to float 
over the map like the zoom controls.

The WMS GetCapabilities does list styles from the layers and contains 
LegendURL elements with links to the actual resource.

"Format/WMSCapabilities/v1_1.js" defines the function GetLegendGraphic, but 
it's not used anywhere else in the OpenLayer(version 2.12) code.

What would be the best way to add the legend over the map?  I could copy and 
modify "Control/Attribution.js", but is there a better way to do this?  Also, 
ideally I would like to make a link with the currently displayed layer and the 
retrieval and display of the legend.

Cheers,

Samuel


More information about the Users mailing list