Cross-dateline rendering fixed for SVG and added for VML renderer.
This commit is contained in:
@@ -114,44 +114,30 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
||||
* False otherwise.
|
||||
*/
|
||||
setExtent: function(extent, resolutionChanged) {
|
||||
OpenLayers.Renderer.Elements.prototype.setExtent.apply(this,
|
||||
arguments);
|
||||
var coordSysUnchanged = OpenLayers.Renderer.Elements.prototype.setExtent.apply(this, arguments);
|
||||
|
||||
var resolution = this.getResolution(),
|
||||
left = -extent.left / resolution,
|
||||
rightLL = -extent.right,
|
||||
top = extent.top / resolution;
|
||||
|
||||
// If the resolution has changed, start over changing the corner, because
|
||||
// the features will redraw.
|
||||
if (resolutionChanged) {
|
||||
this.left = left;
|
||||
this.rightLL = rightLL;
|
||||
this.top = top;
|
||||
// Set the viewbox
|
||||
var extentString = "0 0 " + this.size.w + " " + this.size.h;
|
||||
|
||||
this.rendererRoot.setAttributeNS(null, "viewBox", extentString);
|
||||
this.translate(0, 0);
|
||||
this.translate(this.xOffset, 0);
|
||||
return true;
|
||||
} else {
|
||||
if (this.map.baseLayer && this.map.baseLayer.wrapDateLine) {
|
||||
var oldLeft = this.left * resolution,
|
||||
newLeft = left * resolution,
|
||||
worldBounds = this.map.getMaxExtent(),
|
||||
worldWidth = worldBounds.getWidth(),
|
||||
oldCenterX = (oldLeft + this.rightLL) / 2,
|
||||
newCenterX = (newLeft + rightLL) / 2,
|
||||
worldsAway = Math.round((oldCenterX - newCenterX) / worldWidth);
|
||||
left += worldsAway * worldWidth / resolution;
|
||||
console.log(extent.toString());
|
||||
}
|
||||
var inRange = this.translate(left - this.left, top - this.top);
|
||||
inRange = this.translate(left - this.left + this.xOffset, top - this.top);
|
||||
if (!inRange) {
|
||||
// recenter the coordinate system
|
||||
this.setExtent(extent, true);
|
||||
}
|
||||
return inRange;
|
||||
return coordSysUnchanged && inRange;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -921,7 +907,7 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
||||
var id = this.container.id + "-" + graphicName;
|
||||
|
||||
// check if symbol already exists in the defs
|
||||
var existing = document.getElementById(id)
|
||||
var existing = document.getElementById(id);
|
||||
if (existing != null) {
|
||||
return existing;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user