Rename ol.style.IconAnchorUnits and ol.style.IconOrigin
This commit is contained in:
committed by
Tim Schaub
parent
1beddcd99a
commit
a8d8942fba
+44
-46
@@ -1,6 +1,4 @@
|
||||
goog.provide('ol.style.Icon');
|
||||
goog.provide('ol.style.IconAnchorUnits');
|
||||
goog.provide('ol.style.IconOrigin');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.asserts');
|
||||
@@ -12,28 +10,6 @@ goog.require('ol.style.IconImage');
|
||||
goog.require('ol.style.Image');
|
||||
|
||||
|
||||
/**
|
||||
* Icon anchor units. One of 'fraction', 'pixels'.
|
||||
* @enum {string}
|
||||
*/
|
||||
ol.style.IconAnchorUnits = {
|
||||
FRACTION: 'fraction',
|
||||
PIXELS: 'pixels'
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Icon origin. One of 'bottom-left', 'bottom-right', 'top-left', 'top-right'.
|
||||
* @enum {string}
|
||||
*/
|
||||
ol.style.IconOrigin = {
|
||||
BOTTOM_LEFT: 'bottom-left',
|
||||
BOTTOM_RIGHT: 'bottom-right',
|
||||
TOP_LEFT: 'top-left',
|
||||
TOP_RIGHT: 'top-right'
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Set icon style for vector features.
|
||||
@@ -61,24 +37,24 @@ ol.style.Icon = function(opt_options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.style.IconOrigin}
|
||||
* @type {ol.style.Icon.Origin}
|
||||
*/
|
||||
this.anchorOrigin_ = options.anchorOrigin !== undefined ?
|
||||
options.anchorOrigin : ol.style.IconOrigin.TOP_LEFT;
|
||||
options.anchorOrigin : ol.style.Icon.Origin.TOP_LEFT;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.style.IconAnchorUnits}
|
||||
* @type {ol.style.Icon.AnchorUnits}
|
||||
*/
|
||||
this.anchorXUnits_ = options.anchorXUnits !== undefined ?
|
||||
options.anchorXUnits : ol.style.IconAnchorUnits.FRACTION;
|
||||
options.anchorXUnits : ol.style.Icon.AnchorUnits.FRACTION;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.style.IconAnchorUnits}
|
||||
* @type {ol.style.Icon.AnchorUnits}
|
||||
*/
|
||||
this.anchorYUnits_ = options.anchorYUnits !== undefined ?
|
||||
options.anchorYUnits : ol.style.IconAnchorUnits.FRACTION;
|
||||
options.anchorYUnits : ol.style.Icon.AnchorUnits.FRACTION;
|
||||
|
||||
/**
|
||||
* @type {?string}
|
||||
@@ -139,10 +115,10 @@ ol.style.Icon = function(opt_options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.style.IconOrigin}
|
||||
* @type {ol.style.Icon.Origin}
|
||||
*/
|
||||
this.offsetOrigin_ = options.offsetOrigin !== undefined ?
|
||||
options.offsetOrigin : ol.style.IconOrigin.TOP_LEFT;
|
||||
options.offsetOrigin : ol.style.Icon.Origin.TOP_LEFT;
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -205,33 +181,33 @@ ol.style.Icon.prototype.getAnchor = function() {
|
||||
}
|
||||
var anchor = this.anchor_;
|
||||
var size = this.getSize();
|
||||
if (this.anchorXUnits_ == ol.style.IconAnchorUnits.FRACTION ||
|
||||
this.anchorYUnits_ == ol.style.IconAnchorUnits.FRACTION) {
|
||||
if (this.anchorXUnits_ == ol.style.Icon.AnchorUnits.FRACTION ||
|
||||
this.anchorYUnits_ == ol.style.Icon.AnchorUnits.FRACTION) {
|
||||
if (!size) {
|
||||
return null;
|
||||
}
|
||||
anchor = this.anchor_.slice();
|
||||
if (this.anchorXUnits_ == ol.style.IconAnchorUnits.FRACTION) {
|
||||
if (this.anchorXUnits_ == ol.style.Icon.AnchorUnits.FRACTION) {
|
||||
anchor[0] *= size[0];
|
||||
}
|
||||
if (this.anchorYUnits_ == ol.style.IconAnchorUnits.FRACTION) {
|
||||
if (this.anchorYUnits_ == ol.style.Icon.AnchorUnits.FRACTION) {
|
||||
anchor[1] *= size[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (this.anchorOrigin_ != ol.style.IconOrigin.TOP_LEFT) {
|
||||
if (this.anchorOrigin_ != ol.style.Icon.Origin.TOP_LEFT) {
|
||||
if (!size) {
|
||||
return null;
|
||||
}
|
||||
if (anchor === this.anchor_) {
|
||||
anchor = this.anchor_.slice();
|
||||
}
|
||||
if (this.anchorOrigin_ == ol.style.IconOrigin.TOP_RIGHT ||
|
||||
this.anchorOrigin_ == ol.style.IconOrigin.BOTTOM_RIGHT) {
|
||||
if (this.anchorOrigin_ == ol.style.Icon.Origin.TOP_RIGHT ||
|
||||
this.anchorOrigin_ == ol.style.Icon.Origin.BOTTOM_RIGHT) {
|
||||
anchor[0] = -anchor[0] + size[0];
|
||||
}
|
||||
if (this.anchorOrigin_ == ol.style.IconOrigin.BOTTOM_LEFT ||
|
||||
this.anchorOrigin_ == ol.style.IconOrigin.BOTTOM_RIGHT) {
|
||||
if (this.anchorOrigin_ == ol.style.Icon.Origin.BOTTOM_LEFT ||
|
||||
this.anchorOrigin_ == ol.style.Icon.Origin.BOTTOM_RIGHT) {
|
||||
anchor[1] = -anchor[1] + size[1];
|
||||
}
|
||||
}
|
||||
@@ -294,19 +270,19 @@ ol.style.Icon.prototype.getOrigin = function() {
|
||||
}
|
||||
var offset = this.offset_;
|
||||
|
||||
if (this.offsetOrigin_ != ol.style.IconOrigin.TOP_LEFT) {
|
||||
if (this.offsetOrigin_ != ol.style.Icon.Origin.TOP_LEFT) {
|
||||
var size = this.getSize();
|
||||
var iconImageSize = this.iconImage_.getSize();
|
||||
if (!size || !iconImageSize) {
|
||||
return null;
|
||||
}
|
||||
offset = offset.slice();
|
||||
if (this.offsetOrigin_ == ol.style.IconOrigin.TOP_RIGHT ||
|
||||
this.offsetOrigin_ == ol.style.IconOrigin.BOTTOM_RIGHT) {
|
||||
if (this.offsetOrigin_ == ol.style.Icon.Origin.TOP_RIGHT ||
|
||||
this.offsetOrigin_ == ol.style.Icon.Origin.BOTTOM_RIGHT) {
|
||||
offset[0] = iconImageSize[0] - size[0] - offset[0];
|
||||
}
|
||||
if (this.offsetOrigin_ == ol.style.IconOrigin.BOTTOM_LEFT ||
|
||||
this.offsetOrigin_ == ol.style.IconOrigin.BOTTOM_RIGHT) {
|
||||
if (this.offsetOrigin_ == ol.style.Icon.Origin.BOTTOM_LEFT ||
|
||||
this.offsetOrigin_ == ol.style.Icon.Origin.BOTTOM_RIGHT) {
|
||||
offset[1] = iconImageSize[1] - size[1] - offset[1];
|
||||
}
|
||||
}
|
||||
@@ -362,3 +338,25 @@ ol.style.Icon.prototype.unlistenImageChange = function(listener, thisArg) {
|
||||
ol.events.unlisten(this.iconImage_, ol.events.EventType.CHANGE,
|
||||
listener, thisArg);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Icon anchor units. One of 'fraction', 'pixels'.
|
||||
* @enum {string}
|
||||
*/
|
||||
ol.style.Icon.AnchorUnits = {
|
||||
FRACTION: 'fraction',
|
||||
PIXELS: 'pixels'
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Icon origin. One of 'bottom-left', 'bottom-right', 'top-left', 'top-right'.
|
||||
* @enum {string}
|
||||
*/
|
||||
ol.style.Icon.Origin = {
|
||||
BOTTOM_LEFT: 'bottom-left',
|
||||
BOTTOM_RIGHT: 'bottom-right',
|
||||
TOP_LEFT: 'top-left',
|
||||
TOP_RIGHT: 'top-right'
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user