Skip to content

Commit 2e623d5

Browse files
committed
Website updates
1 parent 0082408 commit 2e623d5

14 files changed

+115
-57
lines changed

dist/en/main/apidoc/module-ol_style_Icon-Icon.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ <h4 class="name">
12641264

12651265
<div class="tag-source">
12661266
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js">style/Icon.js</a>,
1267-
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js#L547">line 547</a>
1267+
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js#L583">line 583</a>
12681268
</div>
12691269

12701270
</div>
@@ -1354,7 +1354,7 @@ <h4 class="name">
13541354

13551355
<div class="tag-source">
13561356
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js">style/Icon.js</a>,
1357-
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js#L417">line 417</a>
1357+
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js#L453">line 453</a>
13581358
</div>
13591359

13601360
</div>
@@ -1582,7 +1582,7 @@ <h4 class="name">
15821582

15831583
<div class="tag-source">
15841584
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js">style/Icon.js</a>,
1585-
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js#L462">line 462</a>
1585+
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js#L498">line 498</a>
15861586
</div>
15871587

15881588
</div>
@@ -1672,7 +1672,7 @@ <h4 class="name">
16721672

16731673
<div class="tag-source">
16741674
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js">style/Icon.js</a>,
1675-
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js#L428">line 428</a>
1675+
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js#L464">line 464</a>
16761676
</div>
16771677

16781678
</div>
@@ -2083,7 +2083,7 @@ <h4 class="name">
20832083

20842084
<div class="tag-source">
20852085
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js">style/Icon.js</a>,
2086-
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js#L522">line 522</a>
2086+
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js#L558">line 558</a>
20872087
</div>
20882088

20892089
</div>
@@ -2173,7 +2173,7 @@ <h4 class="name">
21732173

21742174
<div class="tag-source">
21752175
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js">style/Icon.js</a>,
2176-
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js#L497">line 497</a>
2176+
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js#L533">line 533</a>
21772177
</div>
21782178

21792179
</div>
@@ -2263,7 +2263,7 @@ <h4 class="name">
22632263

22642264
<div class="tag-source">
22652265
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js">style/Icon.js</a>,
2266-
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js#L531">line 531</a>
2266+
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js#L567">line 567</a>
22672267
</div>
22682268

22692269
</div>
@@ -2353,7 +2353,7 @@ <h4 class="name">
23532353

23542354
<div class="tag-source">
23552355
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js">style/Icon.js</a>,
2356-
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js#L586">line 586</a>
2356+
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js#L622">line 622</a>
23572357
</div>
23582358

23592359
</div>
@@ -3076,7 +3076,7 @@ <h4 class="name">
30763076

30773077
<div class="tag-source">
30783078
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js">style/Icon.js</a>,
3079-
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js#L565">line 565</a>
3079+
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js#L601">line 601</a>
30803080
</div>
30813081

30823082
</div>
@@ -3205,7 +3205,7 @@ <h4 class="name">
32053205

32063206
<div class="tag-source">
32073207
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js">style/Icon.js</a>,
3208-
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js#L506">line 506</a>
3208+
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/style/Icon.js#L542">line 542</a>
32093209
</div>
32103210

32113211
</div>

dist/en/main/examples/common.js

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/en/main/examples/common.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/en/main/examples/offscreen-canvas.worker.worker.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/en/main/examples/offscreen-canvas.worker.worker.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/en/main/examples/tiled-layer-rendering-in-offscreen-canvas.worker.worker.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/en/main/examples/tiled-layer-rendering-in-offscreen-canvas.worker.worker.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/en/main/ol/dist/ol.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/en/main/ol/dist/ol.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/en/main/ol/render/canvas/style.js

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,20 @@ function buildIcon(flatStyle, context) {
756756
flatStyle,
757757
prefix + 'anchor-y-units',
758758
);
759-
const color = optionalColorLike(flatStyle, prefix + 'color');
759+
const colorValue = getExpressionValue(flatStyle, prefix + 'color');
760+
let color;
761+
let evaluateColor = null;
762+
if (colorValue !== undefined) {
763+
const isColorExpression =
764+
Array.isArray(colorValue) &&
765+
colorValue.length > 0 &&
766+
typeof colorValue[0] === 'string';
767+
if (isColorExpression) {
768+
evaluateColor = colorLikeEvaluator(flatStyle, prefix + 'color', context);
769+
} else {
770+
color = requireColorLike(colorValue, prefix + 'color');
771+
}
772+
}
760773
const crossOrigin = optionalString(flatStyle, prefix + 'cross-origin');
761774
const offset = optionalNumberArray(flatStyle, prefix + 'offset');
762775
const offsetOrigin = optionalIconOrigin(flatStyle, prefix + 'offset-origin');
@@ -768,22 +781,34 @@ function buildIcon(flatStyle, context) {
768781
prefix + 'declutter-mode',
769782
);
770783

771-
const icon = new Icon({
784+
const iconOptions = {
772785
src,
773786
anchorOrigin,
774787
anchorXUnits,
775788
anchorYUnits,
776-
color,
777789
crossOrigin,
778790
offset,
779791
offsetOrigin,
780792
height,
781793
width,
782794
size,
783795
declutterMode,
784-
});
796+
};
797+
798+
let icon = null;
785799

786800
return function (context) {
801+
if (!icon) {
802+
// lazily create the icon to allow for expression evaluation
803+
const initialColor = evaluateColor ? evaluateColor(context) : color;
804+
icon = new Icon(
805+
initialColor !== undefined
806+
? Object.assign({}, iconOptions, {color: initialColor})
807+
: Object.assign({}, iconOptions),
808+
);
809+
} else if (evaluateColor) {
810+
icon.setColor(evaluateColor(context));
811+
}
787812
if (evaluateOpacity) {
788813
icon.setOpacity(evaluateOpacity(context));
789814
}
@@ -1311,19 +1336,6 @@ function optionalDeclutterMode(flatStyle, property) {
13111336
return encoded;
13121337
}
13131338

1314-
/**
1315-
* @param {FlatStyle} flatStyle The flat style.
1316-
* @param {string} property The symbolizer property.
1317-
* @return {string|Array<number>|undefined} A string or an array of color values or undefined.
1318-
*/
1319-
function optionalColorLike(flatStyle, property) {
1320-
const encoded = flatStyle[property];
1321-
if (encoded === undefined) {
1322-
return undefined;
1323-
}
1324-
return requireColorLike(encoded, property);
1325-
}
1326-
13271339
/**
13281340
* @param {any} value The value.
13291341
* @param {string} property The property.

0 commit comments

Comments
 (0)