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.
|
* {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,24 @@ 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 viewPortWidth = this.map.viewPortDiv.clientWidth;
|
||||||
this.div.style.top = -parseInt(this.map.layerContainerDiv.style.top) + "px";
|
var viewPortHeight = this.map.viewPortDiv.clientHeight;
|
||||||
var extent = this.map.getExtent();
|
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);
|
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 +1019,4 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
CLASS_NAME: "OpenLayers.Layer.Vector"
|
CLASS_NAME: "OpenLayers.Layer.Vector"
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user