Documentation enhancements. No functional change.

This commit is contained in:
Marc Jansen
2012-08-17 23:41:19 +02:00
parent b7063b364c
commit 470dde0e38
+56 -39
View File
@@ -1,4 +1,4 @@
/* Copyright (c) 2006-2012 by OpenLayers Contributors (see authors.txt for /* Copyright (c) 2006-2012 by OpenLayers Contributors (see authors.txt for
* full list of contributors). Published under the 2-clause BSD license. * full list of contributors). Published under the 2-clause BSD license.
* See license.txt in the OpenLayers distribution or repository for the * See license.txt in the OpenLayers distribution or repository for the
* full text of the license. */ * full text of the license. */
@@ -13,11 +13,23 @@
* The MousePosition control displays geographic coordinates of the mouse * The MousePosition control displays geographic coordinates of the mouse
* pointer, as it is moved about the map. * pointer, as it is moved about the map.
* *
* You can use the <prefix>- or <suffix>-properties to provide more information
* about the displayed coordinates to the user:
*
* (code)
* var mousePositionCtrl = new OpenLayers.Control.MousePosition({
* prefix: '<a target="_blank" ' +
* 'href="http://spatialreference.org/ref/epsg/4326/">' +
* 'EPSG:4326</a> coordinates: '
* }
* );
* (end code)
*
* Inherits from: * Inherits from:
* - <OpenLayers.Control> * - <OpenLayers.Control>
*/ */
OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, { OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, {
/** /**
* APIProperty: autoActivate * APIProperty: autoActivate
* {Boolean} Activate the control when it is added to a map. Default is * {Boolean} Activate the control when it is added to a map. Default is
@@ -25,50 +37,55 @@ OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, {
*/ */
autoActivate: true, autoActivate: true,
/** /**
* Property: element * Property: element
* {DOMElement} * {DOMElement}
*/ */
element: null, element: null,
/** /**
* APIProperty: prefix * APIProperty: prefix
* {String} * {String} A string to be prepended to the current pointers coordinates
* when it is rendered. Defaults to the empty string ''.
*/ */
prefix: '', prefix: '',
/** /**
* APIProperty: separator * APIProperty: separator
* {String} * {String} A string to be used to seperate the two coordinates from each
* other. Defaults to the string ', ', which will result in a
* rendered coordinate of e.g. '42.12, 21.22'.
*/ */
separator: ', ', separator: ', ',
/** /**
* APIProperty: suffix * APIProperty: suffix
* {String} * {String} A string to be appended to the current pointers coordinates
* when it is rendered. Defaults to the empty string ''.
*/ */
suffix: '', suffix: '',
/** /**
* APIProperty: numDigits * APIProperty: numDigits
* {Integer} * {Integer} The number of digits each coordinate shall have when being
* rendered, Defaults to 5.
*/ */
numDigits: 5, numDigits: 5,
/** /**
* APIProperty: granularity * APIProperty: granularity
* {Integer} * {Integer}
*/ */
granularity: 10, granularity: 10,
/** /**
* APIProperty: emptyString * APIProperty: emptyString
* {String} Set this to some value to set when the mouse is outside the * {String} Set this to some value to set when the mouse is outside the
* map. * map.
*/ */
emptyString: null, emptyString: null,
/** /**
* Property: lastXy * Property: lastXy
* {<OpenLayers.Pixel>} * {<OpenLayers.Pixel>}
*/ */
@@ -76,14 +93,14 @@ OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, {
/** /**
* APIProperty: displayProjection * APIProperty: displayProjection
* {<OpenLayers.Projection>} The projection in which the * {<OpenLayers.Projection>} The projection in which the mouse position is
* mouse position is displayed * displayed.
*/ */
displayProjection: null, displayProjection: null,
/** /**
* Constructor: OpenLayers.Control.MousePosition * Constructor: OpenLayers.Control.MousePosition
* *
* Parameters: * Parameters:
* options - {Object} Options for control. * options - {Object} Options for control.
*/ */
@@ -109,7 +126,7 @@ OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, {
return false; return false;
} }
}, },
/** /**
* APIMethod: deactivate * APIMethod: deactivate
*/ */
@@ -127,7 +144,7 @@ OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, {
/** /**
* Method: draw * Method: draw
* {DOMElement} * {DOMElement}
*/ */
draw: function() { draw: function() {
OpenLayers.Control.prototype.draw.apply(this, arguments); OpenLayers.Control.prototype.draw.apply(this, arguments);
@@ -136,12 +153,12 @@ OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, {
this.div.top = ""; this.div.top = "";
this.element = this.div; this.element = this.div;
} }
return this.div; return this.div;
}, },
/** /**
* Method: redraw * Method: redraw
*/ */
redraw: function(evt) { redraw: function(evt) {
@@ -160,18 +177,18 @@ OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, {
} }
lonLat = this.map.getLonLatFromPixel(evt.xy); lonLat = this.map.getLonLatFromPixel(evt.xy);
if (!lonLat) { if (!lonLat) {
// map has not yet been properly initialized // map has not yet been properly initialized
return; return;
} }
if (this.displayProjection) { if (this.displayProjection) {
lonLat.transform(this.map.getProjectionObject(), lonLat.transform(this.map.getProjectionObject(),
this.displayProjection ); this.displayProjection );
} }
this.lastXy = evt.xy; this.lastXy = evt.xy;
} }
var newHtml = this.formatOutput(lonLat); var newHtml = this.formatOutput(lonLat);
if (newHtml != this.element.innerHTML) { if (newHtml != this.element.innerHTML) {
@@ -200,7 +217,7 @@ OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, {
var newHtml = var newHtml =
this.prefix + this.prefix +
lonLat.lon.toFixed(digits) + lonLat.lon.toFixed(digits) +
this.separator + this.separator +
lonLat.lat.toFixed(digits) + lonLat.lat.toFixed(digits) +
this.suffix; this.suffix;
return newHtml; return newHtml;