patch for #487 -- dateline wrapping

git-svn-id: http://svn.openlayers.org/trunk/openlayers@3323 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2007-06-12 18:03:59 +00:00
parent 76f9234e3b
commit f56f136523
13 changed files with 519 additions and 25 deletions

View File

@@ -139,6 +139,12 @@ OpenLayers.Layer.prototype = {
/** @type Boolean */
displayOutsideMaxExtent: false,
/** wrapDateLine -- #487 for more info.
*
* @type @Boolean
*/
wrapDateLine: false,
/**
@@ -165,6 +171,10 @@ OpenLayers.Layer.prototype = {
this.events = new OpenLayers.Events(this, this.div,
this.EVENT_TYPES);
}
if (this.wrapDateLine) {
this.displayOutsideMaxExtent = true;
}
},
/**
@@ -616,6 +626,10 @@ OpenLayers.Layer.prototype = {
lonlat = new OpenLayers.LonLat(center.lon + delta_x * res ,
center.lat - delta_y * res);
if (this.wrapDateLine) {
lonlat = lonlat.wrapDateLine(this.maxExtent);
}
} // else { DEBUG STATEMENT }
}
return lonlat;
@@ -641,23 +655,6 @@ OpenLayers.Layer.prototype = {
return px;
},
/**
* Adjusts the extent of a bounds in map units by the layer's gutter
* in pixels.
*
* @param {OpenLayers.Bounds} bounds
* @type OpenLayers.Bounds
* @return A bounds adjusted in height and width by the gutter
*/
adjustBoundsByGutter: function(bounds) {
var mapGutter = this.gutter * this.map.getResolution();
bounds = new OpenLayers.Bounds(bounds.left - mapGutter,
bounds.bottom - mapGutter,
bounds.right + mapGutter,
bounds.top + mapGutter);
return bounds;
},
/**
* Sets the opacity for the entire layer (all images)
* @param {Float} opacity
@@ -681,6 +678,38 @@ OpenLayers.Layer.prototype = {
this.div.style.zIndex = zIdx;
},
/**
* This function will take a bounds, and if wrapDateLine option is set
* on the layer, it will return a bounds which is wrapped around the world.
* We do not wrap for bounds which *cross* the maxExtent.left/right, only
* bounds which are entirely to the left or entirely to the right.
*
* @param {OpenLayers.Bounds} bounds
* @private
*/
adjustBounds: function (bounds) {
if (this.gutter) {
// Adjust the extent of a bounds in map units by the
// layer's gutter in pixels.
var mapGutter = this.gutter * this.map.getResolution();
bounds = new OpenLayers.Bounds(bounds.left - mapGutter,
bounds.bottom - mapGutter,
bounds.right + mapGutter,
bounds.top + mapGutter);
}
if (this.wrapDateLine) {
// wrap around the date line, within the limits of rounding error
var wrappingOptions = {
'rightTolerance':this.getResolution()
};
bounds = bounds.wrapDateLine(this.maxExtent, wrappingOptions);
}
return bounds;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer"
};