replace Pixel argument with simple object (Map.getLonLatFromViewPortPx)

This commit is contained in:
fredj
2012-01-06 13:53:24 +01:00
committed by Frederic Junod
parent 1df5cfa158
commit 8ef0ad8c17
2 changed files with 14 additions and 19 deletions
+10 -16
View File
@@ -213,25 +213,19 @@ OpenLayers.Layer.FixedZoomLevels = OpenLayers.Class({
* bounds of the current viewPort. * bounds of the current viewPort.
*/ */
getExtent: function () { getExtent: function () {
var extent = null;
var size = this.map.getSize(); var size = this.map.getSize();
var tl = this.getLonLatFromViewPortPx({
x: 0, y: 0
});
var br = this.getLonLatFromViewPortPx({
x: size.w, y: size.h
});
var tlPx = new OpenLayers.Pixel(0,0); if ((tl != null) && (br != null)) {
var tlLL = this.getLonLatFromViewPortPx(tlPx); return new OpenLayers.Bounds(tl.lon, br.lat, br.lon, tl.lat);
} else {
var brPx = new OpenLayers.Pixel(size.w, size.h); return null;
var brLL = this.getLonLatFromViewPortPx(brPx);
if ((tlLL != null) && (brLL != null)) {
extent = new OpenLayers.Bounds(tlLL.lon,
brLL.lat,
brLL.lon,
tlLL.lat);
} }
return extent;
}, },
/** /**
+4 -3
View File
@@ -1517,9 +1517,10 @@ OpenLayers.Map = OpenLayers.Class({
*/ */
getCachedCenter: function() { getCachedCenter: function() {
if (!this.center && this.size) { if (!this.center && this.size) {
this.center = this.getLonLatFromViewPortPx( this.center = this.getLonLatFromViewPortPx({
new OpenLayers.Pixel(this.size.w / 2, this.size.h / 2) x: this.size.w / 2,
); y: this.size.h / 2
});
} }
return this.center; return this.center;
}, },