[OpenLayers-Trac] [OpenLayers] #3464: OpenLayers Legend Control

OpenLayers trac-20090302 at openlayers.org
Tue Aug 16 05:36:05 EDT 2011


#3464: OpenLayers Legend Control
-----------------------------+----------------------------------------------
 Reporter:  lissyx           |       Owner:                  
     Type:  feature          |      Status:  new             
 Priority:  minor            |   Milestone:  Future          
Component:  Control          |     Version:  2.10            
 Keywords:  control, legend  |       State:  Needs Discussion
-----------------------------+----------------------------------------------
 Hello,

 While working/prototyping with OpenLayers (I'm still quite a newbie on
 this library), I felt the need for a legend displaying tool, as you can
 find the layerswitcher component. I have no idea if it's a component that
 should/must be available in OpenLayers, but the fact that I saw several
 posts on the web about this topic makes me wonder I'm maybe not alone nor
 that insane.

 So, using OpenLayers.Control.LayerSwitcher as a basis, I wrote a simple
 OpenLayers.Control.Legend component, that takes its place on the right of
 the screen, below LayerSwitcher. The core functionnality is quite simple:
 you pass an option object in the constructor that specifies:
  - min value of the interval of data,
  - max value --,
  - function to call to calculate the color
  - scale size, i.e. how many steps you want for the legend display
  - unit, for formatting purpose (i.e. "value XXX (unit)")
  - expected error value, i.e. a value that denotes a measure error (e.g.
 for a ping measure while surveying outdoor network coverage, this is
 network unrecheable).

 Then it computes the scale to display as an array of objects:
 {{{
 {
   value: Value,
   intlow: Low bound of the value,
   inthigh: High bound of the value,
   color: Hex color string computed by the user's function,
   iserror: Wether it is an expected error
 }
 }}}

 This is used as a model when drawing contents in the redraw() method.

 For my usage (displaying 3G network coverage/latency measured with 'ping'
 over a specific path, high speed train), it works quite well.

-- 
Ticket URL: <http://trac.openlayers.org/ticket/3464>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer


More information about the Trac mailing list