selection. Use CSS ClassName in FF, and onselectstart attribute in IE, to control selection. Fix inappropriate overriding of className in some Control subclasses in order to let this work. Prevents accidental selection of controls in IE and FF. r=euzuro. (Closes #1378) git-svn-id: http://svn.openlayers.org/trunk/openlayers@6727 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
76 lines
1.8 KiB
JavaScript
76 lines
1.8 KiB
JavaScript
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
|
|
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
|
* full text of the license. */
|
|
|
|
|
|
/**
|
|
* @requires OpenLayers/Control.js
|
|
*/
|
|
|
|
/**
|
|
* Class: OpenLayers.Control.Scale
|
|
* Display a small scale indicator on the map.
|
|
* Inherits from:
|
|
* - <OpenLayers.Control>
|
|
*/
|
|
OpenLayers.Control.Scale = OpenLayers.Class(OpenLayers.Control, {
|
|
|
|
/**
|
|
* Parameter: element
|
|
* {DOMElement}
|
|
*/
|
|
element: null,
|
|
|
|
/**
|
|
* Constructor: OpenLayers.Control.Scale
|
|
*
|
|
* Parameters:
|
|
* element - {DOMElement}
|
|
* options - {Object}
|
|
*/
|
|
initialize: function(element, options) {
|
|
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
|
this.element = OpenLayers.Util.getElement(element);
|
|
},
|
|
|
|
/**
|
|
* Method: draw
|
|
*
|
|
* Returns:
|
|
* {DOMElement}
|
|
*/
|
|
draw: function() {
|
|
OpenLayers.Control.prototype.draw.apply(this, arguments);
|
|
if (!this.element) {
|
|
this.element = document.createElement("div");
|
|
this.div.appendChild(this.element);
|
|
}
|
|
this.map.events.register( 'moveend', this, this.updateScale);
|
|
this.updateScale();
|
|
return this.div;
|
|
},
|
|
|
|
/**
|
|
* Method: updateScale
|
|
*/
|
|
updateScale: function() {
|
|
var scale = this.map.getScale();
|
|
if (!scale) {
|
|
return;
|
|
}
|
|
|
|
if (scale >= 9500 && scale <= 950000) {
|
|
scale = Math.round(scale / 1000) + "K";
|
|
} else if (scale >= 950000) {
|
|
scale = Math.round(scale / 1000000) + "M";
|
|
} else {
|
|
scale = Math.round(scale);
|
|
}
|
|
|
|
this.element.innerHTML = OpenLayers.i18n("scale", {'scaleDenom':scale});
|
|
},
|
|
|
|
CLASS_NAME: "OpenLayers.Control.Scale"
|
|
});
|
|
|