diff --git a/lib/OpenLayers/Control/MousePosition.js b/lib/OpenLayers/Control/MousePosition.js index c3b9c41feb..46bff8c13c 100644 --- a/lib/OpenLayers/Control/MousePosition.js +++ b/lib/OpenLayers/Control/MousePosition.js @@ -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. * See license.txt in the OpenLayers distribution or repository for the * full text of the license. */ @@ -13,11 +13,23 @@ * The MousePosition control displays geographic coordinates of the mouse * pointer, as it is moved about the map. * + * You can use the - or -properties to provide more information + * about the displayed coordinates to the user: + * + * (code) + * var mousePositionCtrl = new OpenLayers.Control.MousePosition({ + * prefix: '' + + * 'EPSG:4326 coordinates: ' + * } + * ); + * (end code) + * * Inherits from: * - */ OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, { - + /** * APIProperty: autoActivate * {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, - /** + /** * Property: element - * {DOMElement} + * {DOMElement} */ element: null, - - /** + + /** * APIProperty: prefix - * {String} + * {String} A string to be prepended to the current pointers coordinates + * when it is rendered. Defaults to the empty string ''. */ prefix: '', - - /** + + /** * 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: ', ', - - /** + + /** * APIProperty: suffix - * {String} + * {String} A string to be appended to the current pointers coordinates + * when it is rendered. Defaults to the empty string ''. */ suffix: '', - - /** + + /** * APIProperty: numDigits - * {Integer} + * {Integer} The number of digits each coordinate shall have when being + * rendered, Defaults to 5. */ numDigits: 5, - - /** + + /** * APIProperty: granularity - * {Integer} + * {Integer} */ granularity: 10, /** - * APIProperty: emptyString + * APIProperty: emptyString * {String} Set this to some value to set when the mouse is outside the * map. */ emptyString: null, - - /** + + /** * Property: lastXy * {} */ @@ -76,14 +93,14 @@ OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, { /** * APIProperty: displayProjection - * {} The projection in which the - * mouse position is displayed + * {} The projection in which the mouse position is + * displayed. */ - displayProjection: null, - + displayProjection: null, + /** * Constructor: OpenLayers.Control.MousePosition - * + * * Parameters: * options - {Object} Options for control. */ @@ -109,7 +126,7 @@ OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, { return false; } }, - + /** * APIMethod: deactivate */ @@ -127,7 +144,7 @@ OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, { /** * Method: draw * {DOMElement} - */ + */ draw: function() { OpenLayers.Control.prototype.draw.apply(this, arguments); @@ -136,12 +153,12 @@ OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, { this.div.top = ""; this.element = this.div; } - + return this.div; }, - + /** - * Method: redraw + * Method: redraw */ redraw: function(evt) { @@ -160,18 +177,18 @@ OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, { } lonLat = this.map.getLonLatFromPixel(evt.xy); - if (!lonLat) { + if (!lonLat) { // map has not yet been properly initialized return; - } + } if (this.displayProjection) { - lonLat.transform(this.map.getProjectionObject(), + lonLat.transform(this.map.getProjectionObject(), this.displayProjection ); - } + } this.lastXy = evt.xy; - + } - + var newHtml = this.formatOutput(lonLat); if (newHtml != this.element.innerHTML) { @@ -200,7 +217,7 @@ OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, { var newHtml = this.prefix + lonLat.lon.toFixed(digits) + - this.separator + + this.separator + lonLat.lat.toFixed(digits) + this.suffix; return newHtml;