deal with the dateline in the SVG renderer. Not yet fully functional.
This commit is contained in:
@@ -117,14 +117,16 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
|||||||
OpenLayers.Renderer.Elements.prototype.setExtent.apply(this,
|
OpenLayers.Renderer.Elements.prototype.setExtent.apply(this,
|
||||||
arguments);
|
arguments);
|
||||||
|
|
||||||
var resolution = this.getResolution();
|
var resolution = this.getResolution(),
|
||||||
var left = -extent.left / resolution;
|
left = -extent.left / resolution,
|
||||||
var top = extent.top / resolution;
|
rightLL = -extent.right,
|
||||||
|
top = extent.top / resolution;
|
||||||
|
|
||||||
// If the resolution has changed, start over changing the corner, because
|
// If the resolution has changed, start over changing the corner, because
|
||||||
// the features will redraw.
|
// the features will redraw.
|
||||||
if (resolutionChanged) {
|
if (resolutionChanged) {
|
||||||
this.left = left;
|
this.left = left;
|
||||||
|
this.rightLL = rightLL;
|
||||||
this.top = top;
|
this.top = top;
|
||||||
// Set the viewbox
|
// Set the viewbox
|
||||||
var extentString = "0 0 " + this.size.w + " " + this.size.h;
|
var extentString = "0 0 " + this.size.w + " " + this.size.h;
|
||||||
@@ -133,6 +135,17 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
|||||||
this.translate(0, 0);
|
this.translate(0, 0);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} 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);
|
var inRange = this.translate(left - this.left, top - this.top);
|
||||||
if (!inRange) {
|
if (!inRange) {
|
||||||
// recenter the coordinate system
|
// recenter the coordinate system
|
||||||
@@ -505,7 +518,7 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
|||||||
*/
|
*/
|
||||||
drawCircle: function(node, geometry, radius) {
|
drawCircle: function(node, geometry, radius) {
|
||||||
var resolution = this.getResolution();
|
var resolution = this.getResolution();
|
||||||
var x = (geometry.x / resolution + this.left);
|
var x = ((geometry.x - this.featureDx) / resolution + this.left);
|
||||||
var y = (this.top - geometry.y / resolution);
|
var y = (this.top - geometry.y / resolution);
|
||||||
|
|
||||||
if (this.inValidRange(x, y)) {
|
if (this.inValidRange(x, y)) {
|
||||||
@@ -615,7 +628,7 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
|||||||
*/
|
*/
|
||||||
drawRectangle: function(node, geometry) {
|
drawRectangle: function(node, geometry) {
|
||||||
var resolution = this.getResolution();
|
var resolution = this.getResolution();
|
||||||
var x = (geometry.x / resolution + this.left);
|
var x = ((geometry.x - this.featureDx) / resolution + this.left);
|
||||||
var y = (this.top - geometry.y / resolution);
|
var y = (this.top - geometry.y / resolution);
|
||||||
|
|
||||||
if (this.inValidRange(x, y)) {
|
if (this.inValidRange(x, y)) {
|
||||||
@@ -681,7 +694,7 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
|||||||
drawText: function(featureId, style, location) {
|
drawText: function(featureId, style, location) {
|
||||||
var resolution = this.getResolution();
|
var resolution = this.getResolution();
|
||||||
|
|
||||||
var x = (location.x / resolution + this.left);
|
var x = ((location.x - this.featureDx) / resolution + this.left);
|
||||||
var y = (location.y / resolution - this.top);
|
var y = (location.y / resolution - this.top);
|
||||||
|
|
||||||
var label = this.nodeFactory(featureId + this.LABEL_ID_SUFFIX, "text");
|
var label = this.nodeFactory(featureId + this.LABEL_ID_SUFFIX, "text");
|
||||||
@@ -833,9 +846,9 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
|||||||
var resolution = this.getResolution();
|
var resolution = this.getResolution();
|
||||||
var maxX = this.MAX_PIXEL - this.translationParameters.x;
|
var maxX = this.MAX_PIXEL - this.translationParameters.x;
|
||||||
var maxY = this.MAX_PIXEL - this.translationParameters.y;
|
var maxY = this.MAX_PIXEL - this.translationParameters.y;
|
||||||
var x1 = goodComponent.x / resolution + this.left;
|
var x1 = (goodComponent.x - this.featureDx) / resolution + this.left;
|
||||||
var y1 = this.top - goodComponent.y / resolution;
|
var y1 = this.top - goodComponent.y / resolution;
|
||||||
var x2 = badComponent.x / resolution + this.left;
|
var x2 = (badComponent.x - this.featureDx) / resolution + this.left;
|
||||||
var y2 = this.top - badComponent.y / resolution;
|
var y2 = this.top - badComponent.y / resolution;
|
||||||
var k;
|
var k;
|
||||||
if (x2 < -maxX || x2 > maxX) {
|
if (x2 < -maxX || x2 > maxX) {
|
||||||
@@ -862,7 +875,7 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
|||||||
*/
|
*/
|
||||||
getShortString: function(point) {
|
getShortString: function(point) {
|
||||||
var resolution = this.getResolution();
|
var resolution = this.getResolution();
|
||||||
var x = (point.x / resolution + this.left);
|
var x = ((point.x - this.featureDx) / resolution + this.left);
|
||||||
var y = (this.top - point.y / resolution);
|
var y = (this.top - point.y / resolution);
|
||||||
|
|
||||||
if (this.inValidRange(x, y)) {
|
if (this.inValidRange(x, y)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user