adding ratio to Vector Layer
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.
|
||||
*/
|
||||
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
|
||||
@@ -365,7 +371,7 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
||||
displayError: function() {
|
||||
if (this.reportError) {
|
||||
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);
|
||||
} else {
|
||||
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() {
|
||||
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,24 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
||||
var coordSysUnchanged = true;
|
||||
|
||||
if (!dragging) {
|
||||
this.renderer.root.style.visibility = "hidden";
|
||||
|
||||
this.div.style.left = -parseInt(this.map.layerContainerDiv.style.left) + "px";
|
||||
this.div.style.top = -parseInt(this.map.layerContainerDiv.style.top) + "px";
|
||||
var extent = this.map.getExtent();
|
||||
this.renderer.root.style.visibility = 'hidden';
|
||||
|
||||
var viewPortWidth = this.map.viewPortDiv.clientWidth;
|
||||
var viewPortHeight = this.map.viewPortDiv.clientHeight;
|
||||
var offsetLeft = (viewPortWidth / 2 * this.ratio) - viewPortWidth / 2;
|
||||
offsetLeft += parseInt(this.map.layerContainerDiv.style.left, 10);
|
||||
offsetLeft = -Math.round(offsetLeft);
|
||||
var offsetTop = (viewPortHeight / 2 * this.ratio) - viewPortHeight / 2;
|
||||
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);
|
||||
|
||||
this.renderer.root.style.visibility = "visible";
|
||||
|
||||
this.renderer.root.style.visibility = 'visible';
|
||||
|
||||
// Force a reflow on gecko based browsers to prevent jump/flicker.
|
||||
// This seems to happen on only certain configurations; it was originally
|
||||
@@ -995,4 +1019,4 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Layer.Vector"
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user