Merge branch 'vector-ratio' (closes #113)
This commit is contained in:
@@ -217,6 +217,12 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
|||||||
* {Boolean} Whether the Vector Layer features have been drawn yet.
|
* {Boolean} Whether the Vector Layer features have been drawn yet.
|
||||||
*/
|
*/
|
||||||
drawn: false,
|
drawn: false,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APIProperty: ratio
|
||||||
|
* {Float} This specifies the ratio of the size of the visiblity of the Vector Layer features to the size of the map.
|
||||||
|
*/
|
||||||
|
ratio: 1,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor: OpenLayers.Layer.Vector
|
* Constructor: OpenLayers.Layer.Vector
|
||||||
@@ -365,7 +371,7 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
|||||||
displayError: function() {
|
displayError: function() {
|
||||||
if (this.reportError) {
|
if (this.reportError) {
|
||||||
OpenLayers.Console.userError(OpenLayers.i18n("browserNotSupported",
|
OpenLayers.Console.userError(OpenLayers.i18n("browserNotSupported",
|
||||||
{'renderers':this.renderers.join("\n")}));
|
{renderers: this. renderers.join('\n')}));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -386,7 +392,11 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
|||||||
this.map.removeLayer(this);
|
this.map.removeLayer(this);
|
||||||
} else {
|
} else {
|
||||||
this.renderer.map = this.map;
|
this.renderer.map = this.map;
|
||||||
this.renderer.setSize(this.map.getSize());
|
|
||||||
|
var newSize = this.map.getSize();
|
||||||
|
newSize.w = newSize.w * this.ratio;
|
||||||
|
newSize.h = newSize.h * this.ratio;
|
||||||
|
this.renderer.setSize(newSize);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -435,7 +445,11 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
|||||||
*/
|
*/
|
||||||
onMapResize: function() {
|
onMapResize: function() {
|
||||||
OpenLayers.Layer.prototype.onMapResize.apply(this, arguments);
|
OpenLayers.Layer.prototype.onMapResize.apply(this, arguments);
|
||||||
this.renderer.setSize(this.map.getSize());
|
|
||||||
|
var newSize = this.map.getSize();
|
||||||
|
newSize.w = newSize.w * this.ratio;
|
||||||
|
newSize.h = newSize.h * this.ratio;
|
||||||
|
this.renderer.setSize(newSize);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -463,14 +477,25 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
|||||||
var coordSysUnchanged = true;
|
var coordSysUnchanged = true;
|
||||||
|
|
||||||
if (!dragging) {
|
if (!dragging) {
|
||||||
this.renderer.root.style.visibility = "hidden";
|
this.renderer.root.style.visibility = 'hidden';
|
||||||
|
|
||||||
this.div.style.left = -parseInt(this.map.layerContainerDiv.style.left) + "px";
|
var viewSize = this.map.getSize(),
|
||||||
this.div.style.top = -parseInt(this.map.layerContainerDiv.style.top) + "px";
|
viewWidth = viewSize.w,
|
||||||
var extent = this.map.getExtent();
|
viewHeight = viewSize.h,
|
||||||
|
offsetLeft = (viewWidth / 2 * this.ratio) - viewWidth / 2,
|
||||||
|
offsetTop = (viewHeight / 2 * this.ratio) - viewHeight / 2;
|
||||||
|
offsetLeft += parseInt(this.map.layerContainerDiv.style.left, 10);
|
||||||
|
offsetLeft = -Math.round(offsetLeft);
|
||||||
|
offsetTop += parseInt(this.map.layerContainerDiv.style.top, 10);
|
||||||
|
offsetTop = -Math.round(offsetTop);
|
||||||
|
|
||||||
|
this.div.style.left = offsetLeft + 'px';
|
||||||
|
this.div.style.top = offsetTop + 'px';
|
||||||
|
|
||||||
|
var extent = this.map.getExtent().scale(this.ratio);
|
||||||
coordSysUnchanged = this.renderer.setExtent(extent, zoomChanged);
|
coordSysUnchanged = this.renderer.setExtent(extent, zoomChanged);
|
||||||
|
|
||||||
this.renderer.root.style.visibility = "visible";
|
this.renderer.root.style.visibility = 'visible';
|
||||||
|
|
||||||
// Force a reflow on gecko based browsers to prevent jump/flicker.
|
// Force a reflow on gecko based browsers to prevent jump/flicker.
|
||||||
// This seems to happen on only certain configurations; it was originally
|
// This seems to happen on only certain configurations; it was originally
|
||||||
@@ -995,4 +1020,4 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
CLASS_NAME: "OpenLayers.Layer.Vector"
|
CLASS_NAME: "OpenLayers.Layer.Vector"
|
||||||
});
|
});
|
||||||
@@ -139,7 +139,9 @@ OpenLayers.Renderer = OpenLayers.Class({
|
|||||||
setExtent: function(extent, resolutionChanged) {
|
setExtent: function(extent, resolutionChanged) {
|
||||||
this.extent = extent.clone();
|
this.extent = extent.clone();
|
||||||
if (this.map.baseLayer && this.map.baseLayer.wrapDateLine) {
|
if (this.map.baseLayer && this.map.baseLayer.wrapDateLine) {
|
||||||
this.extent = extent.wrapDateLine(this.map.getMaxExtent());
|
var ratio = extent.getWidth() / this.map.getExtent().getWidth(),
|
||||||
|
extent = extent.scale(1 / ratio);
|
||||||
|
this.extent = extent.wrapDateLine(this.map.getMaxExtent()).scale(ratio);
|
||||||
}
|
}
|
||||||
if (resolutionChanged) {
|
if (resolutionChanged) {
|
||||||
this.resolution = null;
|
this.resolution = null;
|
||||||
|
|||||||
@@ -498,8 +498,9 @@ OpenLayers.Renderer.Elements = OpenLayers.Class(OpenLayers.Renderer, {
|
|||||||
var coordSysUnchanged = OpenLayers.Renderer.prototype.setExtent.apply(this, arguments);
|
var coordSysUnchanged = OpenLayers.Renderer.prototype.setExtent.apply(this, arguments);
|
||||||
var resolution = this.getResolution();
|
var resolution = this.getResolution();
|
||||||
if (this.map.baseLayer && this.map.baseLayer.wrapDateLine) {
|
if (this.map.baseLayer && this.map.baseLayer.wrapDateLine) {
|
||||||
coordSysUnchanged = this.featureDx === 0;
|
|
||||||
var rightOfDateLine,
|
var rightOfDateLine,
|
||||||
|
ratio = extent.getWidth() / this.map.getExtent().getWidth(),
|
||||||
|
extent = extent.scale(1 / ratio),
|
||||||
world = this.map.getMaxExtent();
|
world = this.map.getMaxExtent();
|
||||||
if (world.right > extent.left && world.right < extent.right) {
|
if (world.right > extent.left && world.right < extent.right) {
|
||||||
rightOfDateLine = true;
|
rightOfDateLine = true;
|
||||||
|
|||||||
@@ -614,6 +614,9 @@
|
|||||||
getMaxExtent: function() {
|
getMaxExtent: function() {
|
||||||
return new OpenLayers.Bounds(-180,-90,180,90);
|
return new OpenLayers.Bounds(-180,-90,180,90);
|
||||||
},
|
},
|
||||||
|
getExtent: function() {
|
||||||
|
return r.extent;
|
||||||
|
},
|
||||||
getResolution: function() {
|
getResolution: function() {
|
||||||
return resolution;
|
return resolution;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user