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:
@@ -2288,6 +2288,39 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
px.y = Math.round(px.y);
|
||||
return px;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: getGeodesicPixelSize
|
||||
*
|
||||
* Parameters:
|
||||
* px - {<OpenLayers.Pixel>} The pixel to get the geodesic length for. If
|
||||
* not provided, the center pixel of the map viewport will be used.
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Size>} The geodesic size of the pixel in kilometers.
|
||||
*/
|
||||
getGeodesicPixelSize: function(px) {
|
||||
var lonlat = px ? this.getLonLatFromPixel(px) : (this.getCenter() ||
|
||||
new OpenLayers.LonLat(0, 0));
|
||||
var res = this.getResolution();
|
||||
var left = lonlat.add(-res / 2, 0);
|
||||
var right = lonlat.add(res / 2, 0);
|
||||
var bottom = lonlat.add(0, -res / 2);
|
||||
var top = lonlat.add(0, res / 2);
|
||||
var dest = new OpenLayers.Projection("EPSG:4326");
|
||||
var source = this.getProjectionObject() || dest;
|
||||
if(!source.equals(dest)) {
|
||||
left.transform(source, dest);
|
||||
right.transform(source, dest);
|
||||
bottom.transform(source, dest);
|
||||
top.transform(source, dest);
|
||||
}
|
||||
|
||||
return new OpenLayers.Size(
|
||||
OpenLayers.Util.distVincenty(left, right),
|
||||
OpenLayers.Util.distVincenty(bottom, top)
|
||||
);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user