Add offsetX and offsetY config options for ol.Overlay

This commit is contained in:
Bart van den Eijnden
2014-03-13 15:06:02 +01:00
parent 9f1b695747
commit 3fe3beb28a
2 changed files with 18 additions and 2 deletions

View File

@@ -81,6 +81,18 @@ ol.Overlay = function(options) {
*/
this.stopEvent_ = goog.isDef(options.stopEvent) ? options.stopEvent : true;
/**
* @private
* @type {number}
*/
this.offsetX_ = goog.isDef(options.offsetX) ? options.offsetX : 0;
/**
* @private
* @type {number}
*/
this.offsetY_ = goog.isDef(options.offsetY) ? options.offsetY : 0;
/**
* @private
* @type {Element}
@@ -355,7 +367,7 @@ ol.Overlay.prototype.updatePixelPosition_ = function() {
if (this.rendered_.right_ !== '') {
this.rendered_.right_ = style.right = '';
}
var offsetX = 0;
var offsetX = -this.offsetX_;
if (positioning == ol.OverlayPositioning.BOTTOM_CENTER ||
positioning == ol.OverlayPositioning.CENTER_CENTER ||
positioning == ol.OverlayPositioning.TOP_CENTER) {
@@ -380,7 +392,7 @@ ol.Overlay.prototype.updatePixelPosition_ = function() {
if (this.rendered_.bottom_ !== '') {
this.rendered_.bottom_ = style.bottom = '';
}
var offsetY = 0;
var offsetY = -this.offsetY_;
if (positioning == ol.OverlayPositioning.CENTER_LEFT ||
positioning == ol.OverlayPositioning.CENTER_CENTER ||
positioning == ol.OverlayPositioning.CENTER_RIGHT) {