Added rounding in updateScale().
git-svn-id: http://svn.openlayers.org/trunk/openlayers@925 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -47,7 +47,7 @@ OpenLayers.Control.Scale.prototype =
|
||||
if (!this.element) {
|
||||
this.element = document.createElement("div");
|
||||
this.div.style.right = "3px";
|
||||
this.div.style.bottom = "3px";
|
||||
this.div.style.bottom = "2em";
|
||||
this.div.style.left = "";
|
||||
this.div.style.top = "";
|
||||
this.div.style.display = "block";
|
||||
@@ -55,16 +55,26 @@ OpenLayers.Control.Scale.prototype =
|
||||
this.element.style.fontSize="smaller";
|
||||
this.div.appendChild(this.element);
|
||||
}
|
||||
this.map.events.register( 'moveend', this, this.updateLink);
|
||||
this.map.events.register( 'moveend', this, this.updateScale);
|
||||
this.updateScale();
|
||||
return this.div;
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
updateLink: function() {
|
||||
updateScale: function() {
|
||||
var res = this.map.getResolution();
|
||||
var scale = 1 / (res * self.INCHES_PER_UNIT[self.units] * self.dpi);
|
||||
if (!res) return;
|
||||
|
||||
var scale = res * this.INCHES_PER_UNIT[this.units] * this.dpi;
|
||||
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 / 100) * 100;
|
||||
}
|
||||
this.element.innerHTML = "Scale = 1 : " + scale;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user