diff --git a/externs/olx.js b/externs/olx.js index 4d91ec98a8..bbac0af11d 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -338,7 +338,7 @@ olx.AtPixelOptions.prototype.hitTolerance; * element: (Element|undefined), * offset: (Array.|undefined), * position: (ol.Coordinate|undefined), - * positioning: (ol.Overlay.Positioning|string|undefined), + * positioning: (ol.OverlayPositioning|string|undefined), * stopEvent: (boolean|undefined), * insertFirst: (boolean|undefined), * autoPan: (boolean|undefined), @@ -389,7 +389,7 @@ olx.OverlayOptions.prototype.position; * property. Possible values are `'bottom-left'`, `'bottom-center'`, * `'bottom-right'`, `'center-left'`, `'center-center'`, `'center-right'`, * `'top-left'`, `'top-center'`, and `'top-right'`. Default is `'top-left'`. - * @type {ol.Overlay.Positioning|string|undefined} + * @type {ol.OverlayPositioning|string|undefined} * @api stable */ olx.OverlayOptions.prototype.positioning; diff --git a/src/ol/control/overviewmap.js b/src/ol/control/overviewmap.js index 3806d0d7d1..36ac555acb 100644 --- a/src/ol/control/overviewmap.js +++ b/src/ol/control/overviewmap.js @@ -8,6 +8,7 @@ goog.require('ol.MapProperty'); goog.require('ol.Object'); goog.require('ol.ObjectEventType'); goog.require('ol.Overlay'); +goog.require('ol.OverlayPositioning'); goog.require('ol.ViewProperty'); goog.require('ol.control.Control'); goog.require('ol.coordinate'); @@ -123,7 +124,7 @@ ol.control.OverviewMap = function(opt_options) { */ this.boxOverlay_ = new ol.Overlay({ position: [0, 0], - positioning: ol.Overlay.Positioning.BOTTOM_LEFT, + positioning: ol.OverlayPositioning.BOTTOM_LEFT, element: box }); this.ovmap_.addOverlay(this.boxOverlay_); diff --git a/src/ol/overlay.js b/src/ol/overlay.js index b198b528a0..63e172bb68 100644 --- a/src/ol/overlay.js +++ b/src/ol/overlay.js @@ -3,6 +3,7 @@ goog.provide('ol.Overlay'); goog.require('ol'); goog.require('ol.MapEventType'); goog.require('ol.Object'); +goog.require('ol.OverlayPositioning'); goog.require('ol.dom'); goog.require('ol.events'); goog.require('ol.extent'); @@ -129,8 +130,8 @@ ol.Overlay = function(options) { this.setOffset(options.offset !== undefined ? options.offset : [0, 0]); this.setPositioning(options.positioning !== undefined ? - /** @type {ol.Overlay.Positioning} */ (options.positioning) : - ol.Overlay.Positioning.TOP_LEFT); + /** @type {ol.OverlayPositioning} */ (options.positioning) : + ol.OverlayPositioning.TOP_LEFT); if (options.position !== undefined) { this.setPosition(options.position); @@ -201,13 +202,13 @@ ol.Overlay.prototype.getPosition = function() { /** * Get the current positioning of this overlay. - * @return {ol.Overlay.Positioning} How the overlay is positioned + * @return {ol.OverlayPositioning} How the overlay is positioned * relative to its point on the map. * @observable * @api stable */ ol.Overlay.prototype.getPositioning = function() { - return /** @type {ol.Overlay.Positioning} */ ( + return /** @type {ol.OverlayPositioning} */ ( this.get(ol.Overlay.Property.POSITIONING)); }; @@ -411,7 +412,7 @@ ol.Overlay.prototype.getRect_ = function(element, size) { /** * Set the positioning for this overlay. - * @param {ol.Overlay.Positioning} positioning how the overlay is + * @param {ol.OverlayPositioning} positioning how the overlay is * positioned relative to its point on the map. * @observable * @api stable @@ -467,9 +468,9 @@ ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) { var offsetX = offset[0]; var offsetY = offset[1]; - if (positioning == ol.Overlay.Positioning.BOTTOM_RIGHT || - positioning == ol.Overlay.Positioning.CENTER_RIGHT || - positioning == ol.Overlay.Positioning.TOP_RIGHT) { + if (positioning == ol.OverlayPositioning.BOTTOM_RIGHT || + positioning == ol.OverlayPositioning.CENTER_RIGHT || + positioning == ol.OverlayPositioning.TOP_RIGHT) { if (this.rendered_.left_ !== '') { this.rendered_.left_ = style.left = ''; } @@ -481,9 +482,9 @@ ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) { if (this.rendered_.right_ !== '') { this.rendered_.right_ = style.right = ''; } - if (positioning == ol.Overlay.Positioning.BOTTOM_CENTER || - positioning == ol.Overlay.Positioning.CENTER_CENTER || - positioning == ol.Overlay.Positioning.TOP_CENTER) { + if (positioning == ol.OverlayPositioning.BOTTOM_CENTER || + positioning == ol.OverlayPositioning.CENTER_CENTER || + positioning == ol.OverlayPositioning.TOP_CENTER) { offsetX -= this.element_.offsetWidth / 2; } var left = Math.round(pixel[0] + offsetX) + 'px'; @@ -491,9 +492,9 @@ ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) { this.rendered_.left_ = style.left = left; } } - if (positioning == ol.Overlay.Positioning.BOTTOM_LEFT || - positioning == ol.Overlay.Positioning.BOTTOM_CENTER || - positioning == ol.Overlay.Positioning.BOTTOM_RIGHT) { + if (positioning == ol.OverlayPositioning.BOTTOM_LEFT || + positioning == ol.OverlayPositioning.BOTTOM_CENTER || + positioning == ol.OverlayPositioning.BOTTOM_RIGHT) { if (this.rendered_.top_ !== '') { this.rendered_.top_ = style.top = ''; } @@ -505,9 +506,9 @@ ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) { if (this.rendered_.bottom_ !== '') { this.rendered_.bottom_ = style.bottom = ''; } - if (positioning == ol.Overlay.Positioning.CENTER_LEFT || - positioning == ol.Overlay.Positioning.CENTER_CENTER || - positioning == ol.Overlay.Positioning.CENTER_RIGHT) { + if (positioning == ol.OverlayPositioning.CENTER_LEFT || + positioning == ol.OverlayPositioning.CENTER_CENTER || + positioning == ol.OverlayPositioning.CENTER_RIGHT) { offsetY -= this.element_.offsetHeight / 2; } var top = Math.round(pixel[1] + offsetY) + 'px'; @@ -520,25 +521,6 @@ ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) { }; -/** - * Overlay position: `'bottom-left'`, `'bottom-center'`, `'bottom-right'`, - * `'center-left'`, `'center-center'`, `'center-right'`, `'top-left'`, - * `'top-center'`, `'top-right'` - * @enum {string} - */ -ol.Overlay.Positioning = { - BOTTOM_LEFT: 'bottom-left', - BOTTOM_CENTER: 'bottom-center', - BOTTOM_RIGHT: 'bottom-right', - CENTER_LEFT: 'center-left', - CENTER_CENTER: 'center-center', - CENTER_RIGHT: 'center-right', - TOP_LEFT: 'top-left', - TOP_CENTER: 'top-center', - TOP_RIGHT: 'top-right' -}; - - /** * @enum {string} */ diff --git a/src/ol/overlaypositioning.js b/src/ol/overlaypositioning.js new file mode 100644 index 0000000000..a601f6d6de --- /dev/null +++ b/src/ol/overlaypositioning.js @@ -0,0 +1,19 @@ +goog.provide('ol.OverlayPositioning'); + +/** + * Overlay position: `'bottom-left'`, `'bottom-center'`, `'bottom-right'`, + * `'center-left'`, `'center-center'`, `'center-right'`, `'top-left'`, + * `'top-center'`, `'top-right'` + * @enum {string} + */ +ol.OverlayPositioning = { + BOTTOM_LEFT: 'bottom-left', + BOTTOM_CENTER: 'bottom-center', + BOTTOM_RIGHT: 'bottom-right', + CENTER_LEFT: 'center-left', + CENTER_CENTER: 'center-center', + CENTER_RIGHT: 'center-right', + TOP_LEFT: 'top-left', + TOP_CENTER: 'top-center', + TOP_RIGHT: 'top-right' +};