1
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
2
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
3
* full text of the license. */
7
* @requires OpenLayers/Control.js
11
* Class: OpenLayers.Control.Scale
12
* Display a small scale indicator on the map.
15
* - <OpenLayers.Control>
17
OpenLayers.Control.Scale = OpenLayers.Class(OpenLayers.Control, {
26
* Constructor: OpenLayers.Control.Scale
29
* element - {DOMElement}
32
initialize: function(element, options) {
33
OpenLayers.Control.prototype.initialize.apply(this, [options]);
34
this.element = OpenLayers.Util.getElement(element);
44
OpenLayers.Control.prototype.draw.apply(this, arguments);
46
this.element = document.createElement("div");
47
this.div.appendChild(this.element);
49
this.map.events.register( 'moveend', this, this.updateScale);
57
updateScale: function() {
58
var scale = this.map.getScale();
63
if (scale >= 9500 && scale <= 950000) {
64
scale = Math.round(scale / 1000) + "K";
65
} else if (scale >= 950000) {
66
scale = Math.round(scale / 1000000) + "M";
68
scale = Math.round(scale);
71
this.element.innerHTML = OpenLayers.i18n("scale", {'scaleDenom':scale});
74
CLASS_NAME: "OpenLayers.Control.Scale"