Control.MousePosition.txt 1.51 KB
OpenLayers.Control.MousePosition

A small control which displays the Longitude and Latitude of the current mouse position, by defualt in the lower right of the map viewport.

* Constructor
  OpenLayers.Control.MousePosition({Object|options}) -- Creates a new MousePosition control.
  
  
* Parameters

  element -- if not null, div in which to display the MousePosition
  prefix -- html to precede the longitude value (default: '')
  separator -- html to separate the longitude and latitude values (default: '<br />')
  suffix -- html to follow the latitude value (default: '')
  numdigits -- number of digits to the right of the decimal (default: 5)
  granularity -- Don't refresh display if mouse has moved more than this (default: 10)

prefix, separator, and suffix are used to format the lon/lat values.

With:
   prefix = 'Lon:&nbsp;'
   suffix = '<br />Lat:&nbsp;'
   suffix = ''
   nudigits = 3
Lon/Lat is displayed as:
    Lon: 95.123
	Lat: 35.456

If the mouse has never been over the map, Lon/Lat will equal 0/0.  If the mouse is over the map, Lon/Lat will equal the current mouse position.  If the mouse has been moved off the map, Lon/Lat will equal the value displayed at the time the mouse was moved off the map.

If the mouse is moving slowly, the Lon/Lat will refresh continuously.  If the mouse is moving rapidly, the refresh of Lon/Lat will be suspended until the mouse has slowed down or stopped.  (Trying to update the Lon/Lat value while the mouse is in rapid movemement makes the movement of the mouse unacceptably jerky.)