Moved INCHES_PER_UNIT and DOTS_PER_INCH into Util.js.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1159 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -10,24 +10,12 @@
|
|||||||
OpenLayers.Control.Scale = Class.create();
|
OpenLayers.Control.Scale = Class.create();
|
||||||
OpenLayers.Control.Scale.prototype =
|
OpenLayers.Control.Scale.prototype =
|
||||||
Object.extend( new OpenLayers.Control(), {
|
Object.extend( new OpenLayers.Control(), {
|
||||||
INCHES_PER_UNIT: { // borrowed from MapServer mapscale.c
|
|
||||||
inches: 1.0,
|
|
||||||
ft: 12.0,
|
|
||||||
mi: 63360.0,
|
|
||||||
m: 39.3701,
|
|
||||||
km: 39370.1,
|
|
||||||
dd: 4374754
|
|
||||||
},
|
|
||||||
|
|
||||||
/** @type DOMElement */
|
/** @type DOMElement */
|
||||||
element: null,
|
element: null,
|
||||||
|
|
||||||
/** @type String */
|
/** @type String */
|
||||||
units: 'dd',
|
units: 'dd',
|
||||||
|
|
||||||
/** @type Integer */
|
|
||||||
dpi: 72,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
*
|
*
|
||||||
@@ -68,7 +56,8 @@ OpenLayers.Control.Scale.prototype =
|
|||||||
var res = this.map.getResolution();
|
var res = this.map.getResolution();
|
||||||
if (!res) return;
|
if (!res) return;
|
||||||
|
|
||||||
var scale = res * this.INCHES_PER_UNIT[this.units] * this.dpi;
|
var scale = res * OpenLayers.INCHES_PER_UNIT[this.units]
|
||||||
|
* OpenLayers.DOTS_PER_INCH;
|
||||||
if (scale >= 9500 && scale <= 950000) {
|
if (scale >= 9500 && scale <= 950000) {
|
||||||
scale = Math.round(scale / 1000) + "K";
|
scale = Math.round(scale / 1000) + "K";
|
||||||
} else if (scale >= 950000) {
|
} else if (scale >= 950000) {
|
||||||
|
|||||||
@@ -1115,3 +1115,18 @@ OpenLayers.Util.createUniqueID = function(prefix) {
|
|||||||
}
|
}
|
||||||
return prefix + Math.round(Math.random() * 10000);
|
return prefix + Math.round(Math.random() * 10000);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** constant inches per unit */
|
||||||
|
OpenLayers.INCHES_PER_UNIT = { // borrowed from MapServer mapscale.c
|
||||||
|
inches: 1.0,
|
||||||
|
in: 1.0,
|
||||||
|
ft: 12.0,
|
||||||
|
mi: 63360.0,
|
||||||
|
m: 39.3701,
|
||||||
|
km: 39370.1,
|
||||||
|
dd: 4374754,
|
||||||
|
degrees: 4374754,
|
||||||
|
};
|
||||||
|
|
||||||
|
/** sensible default */
|
||||||
|
OpenLayers.DOTS_PER_INCH = 72;
|
||||||
|
|||||||
Reference in New Issue
Block a user