/**
* BeNomad BeMap JavaScript API - Icon class
*/
/**
* @classdesc
* Base class for icon.
* @public
* @constructor
* @param {object} options See below the available values.
* @param {String} options.src Source of the image. It can be an URL or an folder path.
* @param {double} options.anchorX .
* @param {double} options.anchorY .
* @param {String} options.anchorXUnits Units of the anchorX.
* @param {String} options.anchorYUnits Units of the anchorY.
* @param {float} options.opacity a number between 0 and 1 to define the opacity of the icon. 1 to full opacity and 0 to full transparency.
*/
bemap.Icon = function(options) {
var opts = options || {};
/**
* @type {object}
* @protected
*/
this.native = null;
/**
* @type {String}
* @protected
*/
this.src = opts.src ? opts.src : 'http://openlayers.org/en/v3.18.2/examples/data/icon.png';
/**
* @type {double}
* @protected
*/
this.width = opts.width ? opts.width : null;
/**
* @type {double}
* @protected
*/
this.height = opts.height ? opts.height : null;
/**
* @type {double}
* @protected
*/
this.anchorX = opts.anchorX ? opts.anchorX : 0.5;
/**
* @type {double}
* @protected
*/
this.anchorY = opts.anchorY ? opts.anchorY : 1;
/**
* @type {String}
* @protected
*/
this.anchorXUnits = opts.anchorXUnits ? opts.anchorXUnits : 'fraction';
/**
* {String}
* @protected
*/
this.anchorYUnits = opts.anchorYUnits ? opts.anchorYUnits : 'fraction';
/**
* @type {float}
* @protected
*/
this.opacity = opts.opacity ? opts.opacity : 0;
/**
* @type {float}
* @protected
*/
this.scale = opts.scale ? opts.scale : 1;
};
/**
* Return the Source of the image.
* @public
* @return {String} Return the source of the image.
*/
bemap.Icon.prototype.getSrc = function() {
return this.src;
};
/**
* Set the Source of the image.
* @public
* @return {bemap.Icon} Return this.
*/
bemap.Icon.prototype.setSrc = function(src) {
this.src = src;
return this;
};
/**
* Return the width of the image.
* @public
* @return {double} Return the width of the image.
*/
bemap.Icon.prototype.getWidth = function() {
return this.width;
};
/**
* Set the width of the image.
* @public
* @return {bemap.Icon} Return this.
*/
bemap.Icon.prototype.setWidth = function(width) {
this.width = width;
return this;
};
/**
* Return the height of the image.
* @public
* @return {double} Return the height of the image.
*/
bemap.Icon.prototype.getHeight = function() {
return this.height;
};
/**
* Set the height of the image.
* @public
* @return {bemap.Icon} Return this.
*/
bemap.Icon.prototype.setHeight = function(height) {
this.height = height;
return this;
};
/**
* Return the horizontale anchor of the image.
* @public
* @return {double} Return the horizontale anchor of the image.
*/
bemap.Icon.prototype.getAnchorX = function() {
return this.anchorX;
};
/**
* Set the horizontale anchor of the image.
* @public
* @return {bemap.Icon} Return this.
*/
bemap.Icon.prototype.setAnchorX = function(anchorX) {
this.anchorX = anchorX;
return this;
};
/**
* Return the verticale anchor of the image.
* @public
* @return {double} Return the verticale anchor of the image.
*/
bemap.Icon.prototype.getAnchorY = function() {
return this.anchorY;
};
/**
* Set the verticale anchor of the image.
* @public
* @return {bemap.Icon} Return this.
*/
bemap.Icon.prototype.setAnchorY = function(anchorY) {
this.anchorY = anchorY;
return this;
};
/**
* Return the units horizontale anchor of the image.
* @public
* @return {String} Return the units horizontale anchor of the image.
*/
bemap.Icon.prototype.getAnchorXUnits = function() {
return this.anchorXUnits;
};
/**
* Set the horizontale anchor units the image.
* @public
* @return {bemap.Icon} Return this.
*/
bemap.Icon.prototype.setAnchorXUnits = function(anchorXUnits) {
this.anchorXUnits = anchorXUnits;
return this;
};
/**
* Return the units verticale anchor of the image.
* @public
* @return {String} Return the units verticale anchor of the image.
*/
bemap.Icon.prototype.getAnchorYUnits = function() {
return this.anchorYUnits;
};
/**
* Set the vertical anchor units the image.
* @public
* @return {bemap.Icon} Return this.
*/
bemap.Icon.prototype.setAnchorYUnits = function(anchorYUnits) {
this.anchorYUnits = anchorYUnits;
return this;
};
/**
* Return the opacity the image.
* @public
* @return {float} Return the opacity of the image.
*/
bemap.Icon.prototype.getOpacity = function() {
return this.opacity;
};
/**
* Set the opacity of the image.
* @public
* @return {bemap.Icon} Return this.
*/
bemap.Icon.prototype.setOpacity = function(opacity) {
this.opacity = opacity;
return this;
};