part two of #204 -- all that remains is to write some test functions
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1383 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -336,20 +336,24 @@ OpenLayers.Layer.prototype = {
|
|||||||
|
|
||||||
/** Calculates based on resolution, center, and mapsize
|
/** Calculates based on resolution, center, and mapsize
|
||||||
*
|
*
|
||||||
|
* @param {float} resolution Specific resolution to get an extent for.
|
||||||
|
* If null, this.getResolution() is called
|
||||||
* @returns A Bounds object which represents the lon/lat bounds of the
|
* @returns A Bounds object which represents the lon/lat bounds of the
|
||||||
* current viewPort.
|
* current viewPort.
|
||||||
* @type OpenLayers.Bounds
|
* @type OpenLayers.Bounds
|
||||||
*/
|
*/
|
||||||
getExtent: function () {
|
getExtent: function(resolution) {
|
||||||
var extent = null;
|
var extent = null;
|
||||||
|
|
||||||
var center = this.map.getCenter();
|
var center = this.map.getCenter();
|
||||||
if (center != null) {
|
if (center != null) {
|
||||||
|
|
||||||
var res = this.getResolution();
|
if (resolution == null) {
|
||||||
|
resolution = this.getResolution();
|
||||||
|
}
|
||||||
var size = this.map.getSize();
|
var size = this.map.getSize();
|
||||||
var w_deg = size.w * res;
|
var w_deg = size.w * resolution;
|
||||||
var h_deg = size.h * res;
|
var h_deg = size.h * resolution;
|
||||||
|
|
||||||
extent = new OpenLayers.Bounds(center.lon - w_deg / 2,
|
extent = new OpenLayers.Bounds(center.lon - w_deg / 2,
|
||||||
center.lat - h_deg / 2,
|
center.lat - h_deg / 2,
|
||||||
|
|||||||
@@ -27,6 +27,11 @@
|
|||||||
* taken from the pixel locations (0,0) and the size of the map. But how
|
* taken from the pixel locations (0,0) and the size of the map. But how
|
||||||
* will we be able to do lonlat-px translation without resolution....?
|
* will we be able to do lonlat-px translation without resolution....?
|
||||||
*
|
*
|
||||||
|
* The getZoomForResolution() method is overridden. Instead of indexing into
|
||||||
|
* the resolutions[] array, we call OpenLayers.Layer.getExent(), passing in
|
||||||
|
* the desired resolution. With this extent, we then call getZoomForExtent()
|
||||||
|
*
|
||||||
|
*
|
||||||
* Whenever you implement a layer using OpenLayers.Layer.FixedZoomLevels,
|
* Whenever you implement a layer using OpenLayers.Layer.FixedZoomLevels,
|
||||||
* it is your responsibility to provide the following three functions:
|
* it is your responsibility to provide the following three functions:
|
||||||
*
|
*
|
||||||
@@ -107,6 +112,21 @@ OpenLayers.Layer.FixedZoomLevels.prototype = {
|
|||||||
return extent;
|
return extent;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {float} resolution
|
||||||
|
*
|
||||||
|
* @returns A suitable zoom level for the specified resolution.
|
||||||
|
* If no baselayer is set, returns null.
|
||||||
|
* @type int
|
||||||
|
*/
|
||||||
|
getZoomForResolution: function(resolution) {
|
||||||
|
|
||||||
|
var extent = OpenLayers.Layer.prototype.getExtent.apply(this,
|
||||||
|
[resolution]);
|
||||||
|
|
||||||
|
return this.getZoomForExtent(extent);
|
||||||
|
},
|
||||||
|
|
||||||
/** @final @type String */
|
/** @final @type String */
|
||||||
CLASS_NAME: "FixedZoomLevels.js"
|
CLASS_NAME: "FixedZoomLevels.js"
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user