ol 10.7.1-dev.1765787011335 → 10.7.1-dev.1766068548052

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ol",
3
- "version": "10.7.1-dev.1765787011335",
3
+ "version": "10.7.1-dev.1766068548052",
4
4
  "description": "OpenLayers mapping library",
5
5
  "keywords": [
6
6
  "map",
@@ -756,7 +756,20 @@ function buildIcon(flatStyle, context) {
756
756
  flatStyle,
757
757
  prefix + 'anchor-y-units',
758
758
  );
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
+ }
760
773
  const crossOrigin = optionalString(flatStyle, prefix + 'cross-origin');
761
774
  const offset = optionalNumberArray(flatStyle, prefix + 'offset');
762
775
  const offsetOrigin = optionalIconOrigin(flatStyle, prefix + 'offset-origin');
@@ -768,12 +781,11 @@ function buildIcon(flatStyle, context) {
768
781
  prefix + 'declutter-mode',
769
782
  );
770
783
 
771
- const icon = new Icon({
784
+ const iconOptions = {
772
785
  src,
773
786
  anchorOrigin,
774
787
  anchorXUnits,
775
788
  anchorYUnits,
776
- color,
777
789
  crossOrigin,
778
790
  offset,
779
791
  offsetOrigin,
@@ -781,9 +793,22 @@ function buildIcon(flatStyle, context) {
781
793
  width,
782
794
  size,
783
795
  declutterMode,
784
- });
796
+ };
797
+
798
+ let icon = null;
785
799
 
786
800
  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
+ }
787
812
  if (evaluateOpacity) {
788
813
  icon.setOpacity(evaluateOpacity(context));
789
814
  }
@@ -1311,19 +1336,6 @@ function optionalDeclutterMode(flatStyle, property) {
1311
1336
  return encoded;
1312
1337
  }
1313
1338
 
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
-
1327
1339
  /**
1328
1340
  * @param {any} value The value.
1329
1341
  * @param {string} property The property.
package/style/Icon.d.ts CHANGED
@@ -189,6 +189,16 @@ declare class Icon extends ImageStyle {
189
189
  * @api
190
190
  */
191
191
  getColor(): import("../color.js").Color;
192
+ /**
193
+ * Set the icon color.
194
+ *
195
+ * Warning: Repeatedly setting the color on an icon style
196
+ * causes the icon image to be re-created each time. This can have a
197
+ * severe performance impact.
198
+ *
199
+ * @param {import("../color.js").Color|string|null|undefined} color Color.
200
+ */
201
+ setColor(color: import("../color.js").Color | string | null | undefined): void;
192
202
  /**
193
203
  * Get the image icon.
194
204
  * @param {number} pixelRatio Pixel ratio.
@@ -1 +1 @@
1
- {"version":3,"file":"Icon.d.ts","sourceRoot":"","sources":["Icon.js"],"names":[],"mappings":";;;;8BAYa,UAAU,GAAG,QAAQ;;;;yBAKrB,aAAa,GAAG,cAAc,GAAG,UAAU,GAAG,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AIG;AACH;IACE;;OAEG;IACH,sBAFW,OAAO,EA0MjB;IAtKC;;;OAGG;IACH,gBAAyE;IAEzE;;;OAGG;IACH,0BAA6B;IAE7B;;;OAGG;IACH,sBACwE;IAExE;;;OAGG;IACH,sBACwE;IAExE;;;OAGG;IACH,sBACwE;IAExE;;;OAGG;IACH,qBACgE;IA0ChE;;;OAGG;IACH,eAAyE;IAEzE;;;OAGG;IACH,mBAMC;IAED;;;OAGG;IACH,gBAAqE;IACrE;;;OAGG;IACH,sBACwE;IAExE;;;OAGG;IACH,gBAAmB;IAEnB;;;OAGG;IACH,cAA6D;IAoBvD,qCAA8B;IA4BtC;;;;;OAKG;IACH,kBAJY,IAAI,CAoCf;IA8DD;;;;;;OAMG;IACH,kBAHW,KAAK,CAAC,MAAM,CAAC,QAMvB;IAED;;;;OAIG;IACH,YAHY,OAAO,aAAa,EAAE,KAAK,CAKtC;IAED;;;;;;;;OAQG;IACH,gBAFW,OAAO,aAAa,EAAE,KAAK,GAAC,MAAM,GAAC,IAAI,GAAC,SAAS,QA2B3D;IAED;;;;;;;OAOG;IACH,8BANW,MAAM,GACL,gBAAgB,GAAC,iBAAiB,GAAC,eAAe,GAAC,WAAW,CAOzE;IA6BD;;;OAGG;IACH,iCAHY,gBAAgB,GAAC,iBAAiB,GAAC,eAAe,GAAC,WAAW,CAKzE;IAsCD;;;;OAIG;IACH,UAHY,MAAM,GAAC,SAAS,CAK3B;IAED;;;;OAIG;IACH,YAHW,MAAM,QAWhB;IAYD;;;;OAIG;IACH,YAHY,MAAM,CAYjB;IAED;;;;OAIG;IACH,aAHY,MAAM,CAYjB;CAgDF;uBAtnBsB,YAAY"}
package/style/Icon.js CHANGED
@@ -406,6 +406,42 @@ class Icon extends ImageStyle {
406
406
  return this.color_;
407
407
  }
408
408
 
409
+ /**
410
+ * Set the icon color.
411
+ *
412
+ * Warning: Repeatedly setting the color on an icon style
413
+ * causes the icon image to be re-created each time. This can have a
414
+ * severe performance impact.
415
+ *
416
+ * @param {import("../color.js").Color|string|null|undefined} color Color.
417
+ */
418
+ setColor(color) {
419
+ const nextColor = color ? asArray(color) : null;
420
+ if (
421
+ this.color_ === nextColor ||
422
+ (this.color_ &&
423
+ nextColor &&
424
+ this.color_.length === nextColor.length &&
425
+ this.color_.every((value, index) => value === nextColor[index]))
426
+ ) {
427
+ // Discard if the color hasn't changed.
428
+ return;
429
+ }
430
+
431
+ this.color_ = nextColor;
432
+ const src = this.getSrc();
433
+ const image = src !== undefined ? null : this.getHitDetectionImage();
434
+ const imageState =
435
+ src !== undefined ? ImageState.IDLE : this.iconImage_.getImageState();
436
+ this.iconImage_ = getIconImage(
437
+ image,
438
+ src,
439
+ this.crossOrigin_,
440
+ imageState,
441
+ this.color_,
442
+ );
443
+ }
444
+
409
445
  /**
410
446
  * Get the image icon.
411
447
  * @param {number} pixelRatio Pixel ratio.
package/util.js CHANGED
@@ -33,4 +33,4 @@ export function getUid(obj) {
33
33
  * OpenLayers version.
34
34
  * @type {string}
35
35
  */
36
- export const VERSION = '10.7.1-dev.1765787011335';
36
+ export const VERSION = '10.7.1-dev.1766068548052';