Named exports from ol/style/IconImage
This commit is contained in:
@@ -8,7 +8,7 @@ import {asArray} from '../color.js';
|
|||||||
import {listen, unlisten} from '../events.js';
|
import {listen, unlisten} from '../events.js';
|
||||||
import EventType from '../events/EventType.js';
|
import EventType from '../events/EventType.js';
|
||||||
import IconAnchorUnits from '../style/IconAnchorUnits.js';
|
import IconAnchorUnits from '../style/IconAnchorUnits.js';
|
||||||
import IconImage from '../style/IconImage.js';
|
import {get as getIconImage} from '../style/IconImage.js';
|
||||||
import IconOrigin from '../style/IconOrigin.js';
|
import IconOrigin from '../style/IconOrigin.js';
|
||||||
import ImageStyle from '../style/Image.js';
|
import ImageStyle from '../style/Image.js';
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ const Icon = function(opt_options) {
|
|||||||
* @private
|
* @private
|
||||||
* @type {ol.style.IconImage}
|
* @type {ol.style.IconImage}
|
||||||
*/
|
*/
|
||||||
this.iconImage_ = IconImage.get(
|
this.iconImage_ = getIconImage(
|
||||||
image, /** @type {string} */ (src), imgSize, this.crossOrigin_, imageState, this.color_);
|
image, /** @type {string} */ (src), imgSize, this.crossOrigin_, imageState, this.color_);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -19,8 +19,7 @@ import {iconImageCache} from '../style.js';
|
|||||||
* @param {ol.Color} color Color.
|
* @param {ol.Color} color Color.
|
||||||
* @extends {ol.events.EventTarget}
|
* @extends {ol.events.EventTarget}
|
||||||
*/
|
*/
|
||||||
const IconImage = function(image, src, size, crossOrigin, imageState,
|
const IconImage = function(image, src, size, crossOrigin, imageState, color) {
|
||||||
color) {
|
|
||||||
|
|
||||||
EventTarget.call(this);
|
EventTarget.call(this);
|
||||||
|
|
||||||
@@ -101,16 +100,14 @@ inherits(IconImage, EventTarget);
|
|||||||
* @param {ol.Color} color Color.
|
* @param {ol.Color} color Color.
|
||||||
* @return {ol.style.IconImage} Icon image.
|
* @return {ol.style.IconImage} Icon image.
|
||||||
*/
|
*/
|
||||||
IconImage.get = function(image, src, size, crossOrigin, imageState,
|
export function get(image, src, size, crossOrigin, imageState, color) {
|
||||||
color) {
|
|
||||||
let iconImage = iconImageCache.get(src, crossOrigin, color);
|
let iconImage = iconImageCache.get(src, crossOrigin, color);
|
||||||
if (!iconImage) {
|
if (!iconImage) {
|
||||||
iconImage = new IconImage(
|
iconImage = new IconImage(image, src, size, crossOrigin, imageState, color);
|
||||||
image, src, size, crossOrigin, imageState, color);
|
|
||||||
iconImageCache.set(src, crossOrigin, color, iconImage);
|
iconImageCache.set(src, crossOrigin, color, iconImage);
|
||||||
}
|
}
|
||||||
return iconImage;
|
return iconImage;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import {getUid} from '../../../../src/ol/index.js';
|
import {getUid} from '../../../../src/ol/index.js';
|
||||||
import {iconImageCache} from '../../../../src/ol/style.js';
|
import {iconImageCache} from '../../../../src/ol/style.js';
|
||||||
import Icon from '../../../../src/ol/style/Icon.js';
|
import Icon from '../../../../src/ol/style/Icon.js';
|
||||||
import IconImage from '../../../../src/ol/style/IconImage.js';
|
import IconImage, {get as getIconImage} from '../../../../src/ol/style/IconImage.js';
|
||||||
|
|
||||||
|
|
||||||
describe('ol.style.Icon', function() {
|
describe('ol.style.Icon', function() {
|
||||||
@@ -17,8 +17,7 @@ describe('ol.style.Icon', function() {
|
|||||||
img: canvas,
|
img: canvas,
|
||||||
imgSize: size
|
imgSize: size
|
||||||
});
|
});
|
||||||
expect(IconImage.get(
|
expect(getIconImage(canvas, getUid(canvas), size, '').getImage()).to.eql(canvas);
|
||||||
canvas, getUid(canvas), size, '').getImage()).to.eql(canvas);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('imgSize overrides img.width and img.height', function(done) {
|
it('imgSize overrides img.width and img.height', function(done) {
|
||||||
|
|||||||
Reference in New Issue
Block a user