Fixed ScaleLine when geodesic option is set to true and the map center is beyond the poles. Also added geodesic option to the Scale control. r=tschaub (closes #2600)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10657 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -23,6 +23,15 @@ OpenLayers.Control.Scale = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
element: null,
|
||||
|
||||
/**
|
||||
* APIProperty: geodesic
|
||||
* {Boolean} Use geodesic measurement. Default is false. The recommended
|
||||
* setting for maps in EPSG:4326 is false, and true EPSG:900913. If set to
|
||||
* true, the scale will be calculated based on the horizontal size of the
|
||||
* pixel in the center of the map viewport.
|
||||
*/
|
||||
geodesic: false,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.Scale
|
||||
*
|
||||
@@ -56,7 +65,19 @@ OpenLayers.Control.Scale = OpenLayers.Class(OpenLayers.Control, {
|
||||
* Method: updateScale
|
||||
*/
|
||||
updateScale: function() {
|
||||
var scale = this.map.getScale();
|
||||
var scale;
|
||||
if(this.geodesic === true) {
|
||||
var units = this.map.getUnits();
|
||||
if(!units) {
|
||||
return;
|
||||
}
|
||||
var inches = OpenLayers.INCHES_PER_UNIT;
|
||||
scale = (this.map.getGeodesicPixelSize().w || 0.000001) *
|
||||
inches["km"] * OpenLayers.DOTS_PER_INCH;
|
||||
} else {
|
||||
scale = this.map.getScale();
|
||||
}
|
||||
|
||||
if (!scale) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user