ol 7.0.0-dev.1659137717612 → 7.0.0-dev.1659197169870

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.
@@ -85,7 +85,7 @@ export type Options<VectorSourceType extends import("../source/Vector.js").defau
85
85
  * features that have their own style will be rendered. See {@link module :ol/style/Style~Style} for the default style
86
86
  * which will be used if this is not set.
87
87
  */
88
- style?: import("../style/Style.js").StyleLike | null | undefined;
88
+ style?: import("../style/Style.js").StyleLike | import("../style/flat.js").FlatStyleLike | null | undefined;
89
89
  /**
90
90
  * Background color for the layer. If not specified, no background
91
91
  * will be rendered.
@@ -211,11 +211,16 @@ declare class BaseVectorLayer<VectorSourceType extends import("../source/Vector.
211
211
  * an array of styles. If set to `null`, the layer has no style (a `null` style),
212
212
  * so only features that have their own styles will be rendered in the layer. Call
213
213
  * `setStyle()` without arguments to reset to the default style. See
214
- * {@link module:ol/style/Style~Style} for information on the default style.
215
- * @param {import("../style/Style.js").StyleLike|null} [opt_style] Layer style.
214
+ * [the ol/style/Style module]{@link module:ol/style/Style~Style} for information on the default style.
215
+ *
216
+ * If your layer has a static style, you can use "flat" style object literals instead of
217
+ * using the `Style` and symbolizer constructors (`Fill`, `Stroke`, etc.). See the documentation
218
+ * for the [flat style types]{@link module:ol/style/flat~FlatStyle} to see what properties are supported.
219
+ *
220
+ * @param {import("../style/Style.js").StyleLike|import("../style/flat.js").FlatStyleLike|null} [opt_style] Layer style.
216
221
  * @api
217
222
  */
218
- setStyle(opt_style?: import("../style/Style.js").StyleLike | null | undefined): void;
223
+ setStyle(opt_style?: import("../style/Style.js").StyleLike | import("../style/flat.js").FlatStyleLike | null | undefined): void;
219
224
  }
220
225
  import Layer from "./Layer.js";
221
226
  //# sourceMappingURL=BaseVector.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseVector.d.ts","sourceRoot":"","sources":["BaseVector.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA;;;;;;;;;;;GAWG;AACH;IACE;;OAEG;IACH,iEA0DC;IA/CC;;;OAGG;IACH,mBAC6D;IAE7D;;;OAGG;IACH,sBACiE;IAEjE;;;;OAIG;IACH,eAAkB;IAElB;;;;OAIG;IACH,uBAA+B;IAI/B;;;OAGG;IACH,8BAGW;IAEX;;;OAGG;IACH,gCAGW;IAGb;;OAEG;IACH,gBAFY,OAAO,CAIlB;IAoBD;;OAEG;IACH,mBAFY,MAAM,GAAC,SAAS,CAI3B;IAED;;;OAGG;IACH,yBAHqB,OAAO,eAAe,EAAE,OAAO,QAAE,OAAO,eAAe,EAAE,OAAO,KAAG,MAAM,GAAC,IAAI,GAAC,SAAS,CAO5G;IAED;;;;;OAKG;IACH,YAHY,OAAO,mBAAmB,EAAE,SAAS,GAAC,IAAI,GAAC,SAAS,CAK/D;IAED;;;;OAIG;IACH,oBAHY,OAAO,mBAAmB,EAAE,aAAa,GAAC,SAAS,CAK9D;IAED;;;OAGG;IACH,2BAHY,OAAO,CAKlB;IAED;;;OAGG;IACH,6BAHY,OAAO,CAKlB;IAED;;;OAGG;IACH,4BAFW,OAAO,oBAAoB,EAAE,UAAU,QAOjD;IAED;;;OAGG;IACH,4BAHW,OAAO,cAAc,EAAE,aAAa,GAAC,IAAI,GAAC,SAAS,QAK7D;IAED;;;;;;;;;OASG;IACH,qFAKC;CACF"}
1
+ {"version":3,"file":"BaseVector.d.ts","sourceRoot":"","sources":["BaseVector.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EA;;;;;;;;;;;GAWG;AACH;IACE;;OAEG;IACH,iEA0DC;IA/CC;;;OAGG;IACH,mBAC6D;IAE7D;;;OAGG;IACH,sBACiE;IAEjE;;;;OAIG;IACH,eAAkB;IAElB;;;;OAIG;IACH,uBAA+B;IAI/B;;;OAGG;IACH,8BAGW;IAEX;;;OAGG;IACH,gCAGW;IAGb;;OAEG;IACH,gBAFY,OAAO,CAIlB;IAoBD;;OAEG;IACH,mBAFY,MAAM,GAAC,SAAS,CAI3B;IAED;;;OAGG;IACH,yBAHqB,OAAO,eAAe,EAAE,OAAO,QAAE,OAAO,eAAe,EAAE,OAAO,KAAG,MAAM,GAAC,IAAI,GAAC,SAAS,CAO5G;IAED;;;;;OAKG;IACH,YAHY,OAAO,mBAAmB,EAAE,SAAS,GAAC,IAAI,GAAC,SAAS,CAK/D;IAED;;;;OAIG;IACH,oBAHY,OAAO,mBAAmB,EAAE,aAAa,GAAC,SAAS,CAK9D;IAED;;;OAGG;IACH,2BAHY,OAAO,CAKlB;IAED;;;OAGG;IACH,6BAHY,OAAO,CAKlB;IAED;;;OAGG;IACH,4BAFW,OAAO,oBAAoB,EAAE,UAAU,QAOjD;IAED;;;OAGG;IACH,4BAHW,OAAO,cAAc,EAAE,aAAa,GAAC,IAAI,GAAC,SAAS,QAK7D;IAED;;;;;;;;;;;;;;OAcG;IACH,gIAuCC;CACF"}
@@ -3,10 +3,11 @@
3
3
  */
4
4
  import Layer from './Layer.js';
5
5
  import RBush from 'rbush';
6
- import {
6
+ import Style, {
7
7
  createDefaultStyle,
8
8
  toFunction as toStyleFunction,
9
9
  } from '../style/Style.js';
10
+ import {toStyle} from '../style/flat.js';
10
11
 
11
12
  /**
12
13
  * @template {import("../source/Vector.js").default|import("../source/VectorTile.js").default} VectorSourceType
@@ -49,7 +50,7 @@ import {
49
50
  * the fill and stroke styles of all of those layers regardless of z-index. To opt out of this
50
51
  * behavior and place declutterd features with their own layer configure the layer with a `className`
51
52
  * other than `ol-layer`.
52
- * @property {import("../style/Style.js").StyleLike|null} [style] Layer style. When set to `null`, only
53
+ * @property {import("../style/Style.js").StyleLike|import("../style/flat.js").FlatStyleLike|null} [style] Layer style. When set to `null`, only
53
54
  * features that have their own style will be rendered. See {@link module:ol/style/Style~Style} for the default style
54
55
  * which will be used if this is not set.
55
56
  * @property {import("./Base.js").BackgroundColor} [background] Background color for the layer. If not specified, no background
@@ -249,12 +250,51 @@ class BaseVectorLayer extends Layer {
249
250
  * an array of styles. If set to `null`, the layer has no style (a `null` style),
250
251
  * so only features that have their own styles will be rendered in the layer. Call
251
252
  * `setStyle()` without arguments to reset to the default style. See
252
- * {@link module:ol/style/Style~Style} for information on the default style.
253
- * @param {import("../style/Style.js").StyleLike|null} [opt_style] Layer style.
253
+ * [the ol/style/Style module]{@link module:ol/style/Style~Style} for information on the default style.
254
+ *
255
+ * If your layer has a static style, you can use "flat" style object literals instead of
256
+ * using the `Style` and symbolizer constructors (`Fill`, `Stroke`, etc.). See the documentation
257
+ * for the [flat style types]{@link module:ol/style/flat~FlatStyle} to see what properties are supported.
258
+ *
259
+ * @param {import("../style/Style.js").StyleLike|import("../style/flat.js").FlatStyleLike|null} [opt_style] Layer style.
254
260
  * @api
255
261
  */
256
262
  setStyle(opt_style) {
257
- this.style_ = opt_style !== undefined ? opt_style : createDefaultStyle;
263
+ /**
264
+ * @type {import("../style/Style.js").StyleLike|null}
265
+ */
266
+ let style;
267
+
268
+ if (opt_style === undefined) {
269
+ style = createDefaultStyle;
270
+ } else if (opt_style === null) {
271
+ style = null;
272
+ } else if (typeof opt_style === 'function') {
273
+ style = opt_style;
274
+ } else if (opt_style instanceof Style) {
275
+ style = opt_style;
276
+ } else if (Array.isArray(opt_style)) {
277
+ const len = opt_style.length;
278
+
279
+ /**
280
+ * @type {Array<Style>}
281
+ */
282
+ const styles = new Array(len);
283
+
284
+ for (let i = 0; i < len; ++i) {
285
+ const s = opt_style[i];
286
+ if (s instanceof Style) {
287
+ styles[i] = s;
288
+ } else {
289
+ styles[i] = toStyle(s);
290
+ }
291
+ }
292
+ style = styles;
293
+ } else {
294
+ style = toStyle(opt_style);
295
+ }
296
+
297
+ this.style_ = style;
258
298
  this.styleFunction_ =
259
299
  opt_style === null ? undefined : toStyleFunction(this.style_);
260
300
  this.changed();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ol",
3
- "version": "7.0.0-dev.1659137717612",
3
+ "version": "7.0.0-dev.1659197169870",
4
4
  "description": "OpenLayers mapping library",
5
5
  "keywords": [
6
6
  "map",
@@ -29,6 +29,11 @@ declare class IconImage extends EventTarget {
29
29
  * @type {HTMLImageElement|HTMLCanvasElement}
30
30
  */
31
31
  private image_;
32
+ /**
33
+ * @private
34
+ * @type {string|null}
35
+ */
36
+ private crossOrigin_;
32
37
  /**
33
38
  * @private
34
39
  * @type {Object<number, HTMLCanvasElement>}
@@ -59,6 +64,10 @@ declare class IconImage extends EventTarget {
59
64
  * @type {string|undefined}
60
65
  */
61
66
  private src_;
67
+ /**
68
+ * @private
69
+ */
70
+ private initializeImage_;
62
71
  /**
63
72
  * @private
64
73
  * @return {boolean} The image canvas is tainted.
@@ -1 +1 @@
1
- {"version":3,"file":"IconImage.d.ts","sourceRoot":"","sources":["IconImage.js"],"names":[],"mappings":"AAwRA;;;;;;;;GAQG;AACH,2BARW,gBAAgB,GAAC,iBAAiB,OAClC,MAAM,QACN,OAAO,YAAY,EAAE,IAAI,eACxB,MAAM,iCAEP,OAAO,aAAa,EAAE,KAAK,GAC1B,SAAS,CASpB;;AAvRD;IACE;;;;;;;OAOG;IACH,mBAPW,gBAAgB,GAAC,iBAAiB,OAClC,MAAM,GAAC,SAAS,QAChB,OAAO,YAAY,EAAE,IAAI,eACxB,MAAM,iCAEP,OAAO,aAAa,EAAE,KAAK,EA6DrC;IAxDC;;;OAGG;IACH,2BAA8B;IAE9B;;;OAGG;IACH,eAA0C;IAM1C;;;OAGG;IACH,gBAAiB;IAEjB;;;OAGG;IACH,eAAmB;IAEnB;;;OAGG;IACH,kBAAqB;IAErB;;;OAGG;IACH,oBAA6B;IAE7B;;;OAGG;IACH,cAAiB;IAEjB;;;OAGG;IACH,aAAe;IAQjB;;;OAGG;IACH,mBAeC;IAPK,8BAAqB;IAS3B;;OAEG;IACH,6BAEC;IAED;;OAEG;IACH,0BAIC;IAED;;OAEG;IACH,yBAUC;IAED;;;OAGG;IACH,qBAHW,MAAM,GACL,gBAAgB,GAAC,iBAAiB,CAK7C;IAED;;;OAGG;IACH,0BAHW,MAAM,GACL,MAAM,CAKjB;IAED;;OAEG;IACH,qBAEC;IAED;;OAEG;IACH,wBAFY,gBAAgB,GAAC,iBAAiB,CAe7C;IAED;;;OAGG;IACH,WAFY,OAAO,YAAY,EAAE,IAAI,CAIpC;IAED;;OAEG;IACH,UAFY,MAAM,GAAC,SAAS,CAI3B;IAED;;OAEG;IACH,aAcC;IAED;;;OAGG;IACH,sBA6CC;IAED;;;;OAIG;IACH,uBAKC;CACF"}
1
+ {"version":3,"file":"IconImage.d.ts","sourceRoot":"","sources":["IconImage.js"],"names":[],"mappings":"AA+SA;;;;;;;;GAQG;AACH,2BARW,gBAAgB,GAAC,iBAAiB,OAClC,MAAM,QACN,OAAO,YAAY,EAAE,IAAI,eACxB,MAAM,iCAEP,OAAO,aAAa,EAAE,KAAK,GAC1B,SAAS,CASpB;;AA9SD;IACE;;;;;;;OAOG;IACH,mBAPW,gBAAgB,GAAC,iBAAiB,OAClC,MAAM,GAAC,SAAS,QAChB,OAAO,YAAY,EAAE,IAAI,eACxB,MAAM,iCAEP,OAAO,aAAa,EAAE,KAAK,EA+DrC;IA1DC;;;OAGG;IACH,2BAA8B;IAE9B;;;OAGG;IACH,eAAmB;IAEnB;;;OAGG;IACH,qBAA+B;IAE/B;;;OAGG;IACH,gBAAiB;IAEjB;;;OAGG;IACH,eAAmB;IAEnB;;;OAGG;IACH,kBAAqB;IAErB;;;OAGG;IACH,oBAA6B;IAE7B;;;OAGG;IACH,cAAiB;IAEjB;;;OAGG;IACH,aAAe;IAQjB;;OAEG;IACH,yBAKC;IAED;;;OAGG;IACH,mBAeC;IAPK,8BAAqB;IAS3B;;OAEG;IACH,6BAEC;IAED;;OAEG;IACH,0BAIC;IAED;;OAEG;IACH,yBAUC;IAED;;;OAGG;IACH,qBAHW,MAAM,GACL,gBAAgB,GAAC,iBAAiB,CAQ7C;IAED;;;OAGG;IACH,0BAHW,MAAM,GACL,MAAM,CAKjB;IAED;;OAEG;IACH,qBAEC;IAED;;OAEG;IACH,wBAFY,gBAAgB,GAAC,iBAAiB,CAkB7C;IAED;;;OAGG;IACH,WAFY,OAAO,YAAY,EAAE,IAAI,CAIpC;IAED;;OAEG;IACH,UAFY,MAAM,GAAC,SAAS,CAI3B;IAED;;OAEG;IACH,aAmBC;IAED;;;OAGG;IACH,sBA6CC;IAED;;;;OAIG;IACH,uBAKC;CACF"}
@@ -37,11 +37,13 @@ class IconImage extends EventTarget {
37
37
  * @private
38
38
  * @type {HTMLImageElement|HTMLCanvasElement}
39
39
  */
40
- this.image_ = !image ? new Image() : image;
40
+ this.image_ = image;
41
41
 
42
- if (crossOrigin !== null) {
43
- /** @type {HTMLImageElement} */ (this.image_).crossOrigin = crossOrigin;
44
- }
42
+ /**
43
+ * @private
44
+ * @type {string|null}
45
+ */
46
+ this.crossOrigin_ = crossOrigin;
45
47
 
46
48
  /**
47
49
  * @private
@@ -85,6 +87,16 @@ class IconImage extends EventTarget {
85
87
  this.tainted_;
86
88
  }
87
89
 
90
+ /**
91
+ * @private
92
+ */
93
+ initializeImage_() {
94
+ this.image_ = new Image();
95
+ if (this.crossOrigin_ !== null) {
96
+ this.image_.crossOrigin = this.crossOrigin_;
97
+ }
98
+ }
99
+
88
100
  /**
89
101
  * @private
90
102
  * @return {boolean} The image canvas is tainted.
@@ -142,6 +154,9 @@ class IconImage extends EventTarget {
142
154
  * @return {HTMLImageElement|HTMLCanvasElement} Image or Canvas element.
143
155
  */
144
156
  getImage(pixelRatio) {
157
+ if (!this.image_) {
158
+ this.initializeImage_();
159
+ }
145
160
  this.replaceColor_(pixelRatio);
146
161
  return this.canvas_[pixelRatio] ? this.canvas_[pixelRatio] : this.image_;
147
162
  }
@@ -166,6 +181,9 @@ class IconImage extends EventTarget {
166
181
  * @return {HTMLImageElement|HTMLCanvasElement} Image element.
167
182
  */
168
183
  getHitDetectionImage() {
184
+ if (!this.image_) {
185
+ this.initializeImage_();
186
+ }
169
187
  if (!this.hitDetectionImage_) {
170
188
  if (this.isTainted_()) {
171
189
  const width = this.size_[0];
@@ -199,19 +217,24 @@ class IconImage extends EventTarget {
199
217
  * Load not yet loaded URI.
200
218
  */
201
219
  load() {
202
- if (this.imageState_ == ImageState.IDLE) {
203
- this.imageState_ = ImageState.LOADING;
204
- try {
205
- /** @type {HTMLImageElement} */ (this.image_).src = this.src_;
206
- } catch (e) {
207
- this.handleImageError_();
208
- }
209
- this.unlisten_ = listenImage(
210
- this.image_,
211
- this.handleImageLoad_.bind(this),
212
- this.handleImageError_.bind(this)
213
- );
220
+ if (this.imageState_ !== ImageState.IDLE) {
221
+ return;
222
+ }
223
+ if (!this.image_) {
224
+ this.initializeImage_();
225
+ }
226
+
227
+ this.imageState_ = ImageState.LOADING;
228
+ try {
229
+ /** @type {HTMLImageElement} */ (this.image_).src = this.src_;
230
+ } catch (e) {
231
+ this.handleImageError_();
214
232
  }
233
+ this.unlisten_ = listenImage(
234
+ this.image_,
235
+ this.handleImageLoad_.bind(this),
236
+ this.handleImageError_.bind(this)
237
+ );
215
238
  }
216
239
 
217
240
  /**
@@ -0,0 +1,597 @@
1
+ /**
2
+ * For static styling, the [layer.setStyle()]{@link module:ol/layer/Vector~VectorLayer#setStyle} method
3
+ * can be called with an object literal that has fill, stroke, text, icon, regular shape, and/or circle properties.
4
+ * @api
5
+ *
6
+ * @typedef {FlatFill & FlatStroke & FlatText & FlatIcon & FlatShape & FlatCircle} FlatStyle
7
+ */
8
+ /**
9
+ * A flat style literal or an array of the same.
10
+ *
11
+ * @typedef {FlatStyle|Array<FlatStyle>} FlatStyleLike
12
+ */
13
+ /**
14
+ * Fill style properties applied to polygon features.
15
+ *
16
+ * @typedef {Object} FlatFill
17
+ * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [fill-color] The fill color.
18
+ */
19
+ /**
20
+ * Stroke style properties applied to line strings and polygon boundaries. To apply a stroke, at least one of
21
+ * `stroke-color` or `stroke-width` must be provided.
22
+ *
23
+ * @typedef {Object} FlatStroke
24
+ * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [stroke-color] The stroke color.
25
+ * @property {number} [stroke-width] Stroke pixel width.
26
+ * @property {CanvasLineCap} [stroke-line-cap='round'] Line cap style: `butt`, `round`, or `square`.
27
+ * @property {CanvasLineJoin} [stroke-line-join='round'] Line join style: `bevel`, `round`, or `miter`.
28
+ * @property {Array<number>} [stroke-line-dash] Line dash pattern.
29
+ * @property {number} [stroke-line-dash-offset=0] Line dash offset.
30
+ * @property {number} [stroke-miter-limit=10] Miter limit.
31
+ */
32
+ /**
33
+ * Label style properties applied to all features. At a minimum, a `text-value` must be provided.
34
+ *
35
+ * @typedef {Object} FlatText
36
+ * @property {string|Array<string>} [text-value] Text content or rich text content. For plain text provide a string, which can
37
+ * contain line breaks (`\n`). For rich text provide an array of text/font tuples. A tuple consists of the text to
38
+ * render and the font to use (or `''` to use the text style's font). A line break has to be a separate tuple (i.e. `'\n', ''`).
39
+ * **Example:** `['foo', 'bold 10px sans-serif', ' bar', 'italic 10px sans-serif', ' baz', '']` will yield "**foo** *bar* baz".
40
+ * **Note:** Rich text is not supported for the immediate rendering API.
41
+ * @property {string} [text-font] Font style as CSS `font` value, see:
42
+ * https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/font. Default is `'10px sans-serif'`
43
+ * @property {number} [text-max-angle=Math.PI/4] When `text-placement` is set to `'line'`, allow a maximum angle between adjacent characters.
44
+ * The expected value is in radians, and the default is 45° (`Math.PI / 4`).
45
+ * @property {number} [text-offset-x=0] Horizontal text offset in pixels. A positive will shift the text right.
46
+ * @property {number} [text-offset-y=0] Vertical text offset in pixels. A positive will shift the text down.
47
+ * @property {boolean} [text-overflow=false] For polygon labels or when `placement` is set to `'line'`, allow text to exceed
48
+ * the width of the polygon at the label position or the length of the path that it follows.
49
+ * @property {import("./Text.js").TextPlacement} [text-placement='point'] Text placement.
50
+ * @property {number|import("../size.js").Size} [text-scale] Scale.
51
+ * @property {boolean} [text-rotate-with-view=false] Whether to rotate the text with the view.
52
+ * @property {number} [text-rotation=0] Rotation in radians (positive rotation clockwise).
53
+ * @property {CanvasTextAlign} [text-align] Text alignment. Possible values: `'left'`, `'right'`, `'center'`, `'end'` or `'start'`.
54
+ * Default is `'center'` for `text-placement: 'point'`. For `text-placement: 'line'`, the default is to let the renderer choose a
55
+ * placement where `text-max-angle` is not exceeded.
56
+ * @property {import('./Text.js').TextJustify} [text-justify] Text justification within the text box.
57
+ * If not set, text is justified towards the `textAlign` anchor.
58
+ * Otherwise, use options `'left'`, `'center'`, or `'right'` to justify the text within the text box.
59
+ * **Note:** `text-justify` is ignored for immediate rendering and also for `text-placement: 'line'`.
60
+ * @property {CanvasTextBaseline} [text-baseline='middle'] Text base line. Possible values: `'bottom'`, `'top'`, `'middle'`, `'alphabetic'`,
61
+ * `'hanging'`, `'ideographic'`.
62
+ * @property {Array<number>} [text-padding=[0, 0, 0, 0]] Padding in pixels around the text for decluttering and background. The order of
63
+ * values in the array is `[top, right, bottom, left]`.
64
+ * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [text-fill-color] The fill color.
65
+ * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [text-background-fill-color] The fill color.
66
+ * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [text-stroke-color] The stroke color.
67
+ * @property {CanvasLineCap} [text-stroke-line-cap='round'] Line cap style: `butt`, `round`, or `square`.
68
+ * @property {CanvasLineJoin} [text-stroke-line-join='round'] Line join style: `bevel`, `round`, or `miter`.
69
+ * @property {Array<number>} [text-stroke-line-dash] Line dash pattern.
70
+ * @property {number} [text-stroke-line-dash-offset=0] Line dash offset.
71
+ * @property {number} [text-stroke-miter-limit=10] Miter limit.
72
+ * @property {number} [text-stroke-width] Stroke pixel width.
73
+ * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [text-background-stroke-color] The stroke color.
74
+ * @property {CanvasLineCap} [text-background-stroke-line-cap='round'] Line cap style: `butt`, `round`, or `square`.
75
+ * @property {CanvasLineJoin} [text-background-stroke-line-join='round'] Line join style: `bevel`, `round`, or `miter`.
76
+ * @property {Array<number>} [text-background-stroke-line-dash] Line dash pattern.
77
+ * @property {number} [text-background-stroke-line-dash-offset=0] Line dash offset.
78
+ * @property {number} [text-background-stroke-miter-limit=10] Miter limit.
79
+ * @property {number} [text-background-stroke-width] Stroke pixel width.
80
+ */
81
+ /**
82
+ * Icon style properties applied to point features. One of `icon-src` or `icon-img` must be provided to render
83
+ * points with an icon.
84
+ *
85
+ * @typedef {Object} FlatIcon
86
+ * @property {string} [icon-src] Image source URI.
87
+ * @property {HTMLImageElement|HTMLCanvasElement} [icon-img] Image object for the icon. If the `icon-src` option is not provided then the
88
+ * provided image must already be loaded. And in that case, it is required
89
+ * to provide the size of the image, with the `icon-img-size` option.
90
+ * @property {import("../size.js").Size} [icon-img-size] Image size in pixels. Only required if `icon-img` is set and `icon-src` is not.
91
+ * The provided size needs to match the actual size of the image.
92
+ * @property {Array<number>} [icon-anchor=[0.5, 0.5]] Anchor. Default value is the icon center.
93
+ * @property {import("./Icon.js").IconOrigin} [icon-anchor-origin='top-left'] Origin of the anchor: `bottom-left`, `bottom-right`,
94
+ * `top-left` or `top-right`.
95
+ * @property {import("./Icon.js").IconAnchorUnits} [icon-anchor-x-units='fraction'] Units in which the anchor x value is
96
+ * specified. A value of `'fraction'` indicates the x value is a fraction of the icon. A value of `'pixels'` indicates
97
+ * the x value in pixels.
98
+ * @property {import("./Icon.js").IconAnchorUnits} [icon-anchor-y-units='fraction'] Units in which the anchor y value is
99
+ * specified. A value of `'fraction'` indicates the y value is a fraction of the icon. A value of `'pixels'` indicates
100
+ * the y value in pixels.
101
+ * @property {import("../color.js").Color|string} [icon-color] Color to tint the icon. If not specified,
102
+ * the icon will be left as is.
103
+ * @property {null|string} [icon-cross-origin] The `crossOrigin` attribute for loaded images. Note that you must provide a
104
+ * `icon-cross-origin` value if you want to access pixel data with the Canvas renderer.
105
+ * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
106
+ * @property {Array<number>} [icon-offset=[0, 0]] Offset, which, together with the size and the offset origin, define the
107
+ * sub-rectangle to use from the original icon image.
108
+ * @property {Array<number>} [icon-displacement=[0,0]] Displacement of the icon.
109
+ * @property {import("./Icon.js").IconOrigin} [icon-offset-origin='top-left'] Origin of the offset: `bottom-left`, `bottom-right`,
110
+ * `top-left` or `top-right`.
111
+ * @property {number} [icon-opacity=1] Opacity of the icon.
112
+ * @property {number|import("../size.js").Size} [icon-scale=1] Scale.
113
+ * @property {number} [icon-rotation=0] Rotation in radians (positive rotation clockwise).
114
+ * @property {boolean} [icon-rotate-with-view=false] Whether to rotate the icon with the view.
115
+ * @property {import("../size.js").Size} [icon-size] Icon size in pixel. Can be used together with `icon-offset` to define the
116
+ * sub-rectangle to use from the origin (sprite) icon image.
117
+ * @property {"declutter"|"obstacle"|"none"|undefined} [icon-declutter-mode] Declutter mode
118
+ */
119
+ /**
120
+ * Regular shape style properties for rendering point features. At least `shape-points` must be provided.
121
+ *
122
+ * @typedef {Object} FlatShape
123
+ * @property {number} [shape-points] Number of points for stars and regular polygons. In case of a polygon, the number of points
124
+ * is the number of sides.
125
+ * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [shape-fill-color] The fill color.
126
+ * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [shape-stroke-color] The stroke color.
127
+ * @property {number} [shape-stroke-width] Stroke pixel width.
128
+ * @property {CanvasLineCap} [shape-stroke-line-cap='round'] Line cap style: `butt`, `round`, or `square`.
129
+ * @property {CanvasLineJoin} [shape-stroke-line-join='round'] Line join style: `bevel`, `round`, or `miter`.
130
+ * @property {Array<number>} [shape-stroke-line-dash] Line dash pattern.
131
+ * @property {number} [shape-stroke-line-dash-offset=0] Line dash offset.
132
+ * @property {number} [shape-stroke-miter-limit=10] Miter limit.
133
+ * @property {number} [shape-radius] Radius of a regular polygon.
134
+ * @property {number} [shape-radius1] First radius of a star. Ignored if radius is set.
135
+ * @property {number} [shape-radius2] Second radius of a star.
136
+ * @property {number} [shape-angle=0] Shape's angle in radians. A value of 0 will have one of the shape's point facing up.
137
+ * @property {Array<number>} [shape-displacement=[0,0]] Displacement of the shape
138
+ * @property {number} [shape-rotation=0] Rotation in radians (positive rotation clockwise).
139
+ * @property {boolean} [shape-rotate-with-view=false] Whether to rotate the shape with the view.
140
+ * @property {number|import("../size.js").Size} [shape-scale=1] Scale. Unless two dimensional scaling is required a better
141
+ * result may be obtained with appropriate settings for `shape-radius`, `shape-radius1` and `shape-radius2`.
142
+ * @property {"declutter"|"obstacle"|"none"|undefined} [shape-declutter-mode] Declutter mode.
143
+ */
144
+ /**
145
+ * Circle style properties for rendering point features. At least `circle-radius` must be provided.
146
+ *
147
+ * @typedef {Object} FlatCircle
148
+ * @property {number} [circle-radius] Circle radius.
149
+ * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [circle-fill-color] The fill color.
150
+ * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [circle-stroke-color] The stroke color.
151
+ * @property {number} [circle-stroke-width] Stroke pixel width.
152
+ * @property {CanvasLineCap} [circle-stroke-line-cap='round'] Line cap style: `butt`, `round`, or `square`.
153
+ * @property {CanvasLineJoin} [circle-stroke-line-join='round'] Line join style: `bevel`, `round`, or `miter`.
154
+ * @property {Array<number>} [circle-stroke-line-dash] Line dash pattern.
155
+ * @property {number} [circle-stroke-line-dash-offset=0] Line dash offset.
156
+ * @property {number} [circle-stroke-miter-limit=10] Miter limit.
157
+ * @property {Array<number>} [circle-displacement=[0,0]] displacement
158
+ * @property {number|import("../size.js").Size} [circle-scale=1] Scale. A two dimensional scale will produce an ellipse.
159
+ * Unless two dimensional scaling is required a better result may be obtained with an appropriate setting for `circle-radius`.
160
+ * @property {number} [circle-rotation=0] Rotation in radians
161
+ * (positive rotation clockwise, meaningful only when used in conjunction with a two dimensional scale).
162
+ * @property {boolean} [circle-rotate-with-view=false] Whether to rotate the shape with the view
163
+ * (meaningful only when used in conjunction with a two dimensional scale).
164
+ * @property {"declutter"|"obstacle"|"none"|undefined} [circle-declutter-mode] Declutter mode
165
+ */
166
+ /**
167
+ * @param {FlatStyle} flatStyle A flat style literal.
168
+ * @return {import("./Style.js").default} A style instance.
169
+ */
170
+ export function toStyle(flatStyle: FlatStyle): import("./Style.js").default;
171
+ /**
172
+ * For static styling, the [layer.setStyle()]{@link module :ol/layer/Vector~VectorLayer#setStyle} method
173
+ * can be called with an object literal that has fill, stroke, text, icon, regular shape, and/or circle properties.
174
+ */
175
+ export type FlatStyle = FlatFill & FlatStroke & FlatText & FlatIcon & FlatShape & FlatCircle;
176
+ /**
177
+ * A flat style literal or an array of the same.
178
+ */
179
+ export type FlatStyleLike = FlatStyle | Array<FlatStyle>;
180
+ /**
181
+ * Fill style properties applied to polygon features.
182
+ */
183
+ export type FlatFill = {
184
+ /**
185
+ * The fill color.
186
+ */
187
+ "fill-color"?: import("../color.js").Color | import("../colorlike.js").ColorLike | undefined;
188
+ };
189
+ /**
190
+ * Stroke style properties applied to line strings and polygon boundaries. To apply a stroke, at least one of
191
+ * `stroke-color` or `stroke-width` must be provided.
192
+ */
193
+ export type FlatStroke = {
194
+ /**
195
+ * The stroke color.
196
+ */
197
+ "stroke-color"?: import("../color.js").Color | import("../colorlike.js").ColorLike | undefined;
198
+ /**
199
+ * Stroke pixel width.
200
+ */
201
+ "stroke-width"?: number | undefined;
202
+ /**
203
+ * Line cap style: `butt`, `round`, or `square`.
204
+ */
205
+ "stroke-line-cap"?: CanvasLineCap | undefined;
206
+ /**
207
+ * Line join style: `bevel`, `round`, or `miter`.
208
+ */
209
+ "stroke-line-join"?: CanvasLineJoin | undefined;
210
+ /**
211
+ * Line dash pattern.
212
+ */
213
+ "stroke-line-dash"?: number[] | undefined;
214
+ /**
215
+ * Line dash offset.
216
+ */
217
+ "stroke-line-dash-offset"?: number | undefined;
218
+ /**
219
+ * Miter limit.
220
+ */
221
+ "stroke-miter-limit"?: number | undefined;
222
+ };
223
+ /**
224
+ * Label style properties applied to all features. At a minimum, a `text-value` must be provided.
225
+ */
226
+ export type FlatText = {
227
+ /**
228
+ * Text content or rich text content. For plain text provide a string, which can
229
+ * contain line breaks (`\n`). For rich text provide an array of text/font tuples. A tuple consists of the text to
230
+ * render and the font to use (or `''` to use the text style's font). A line break has to be a separate tuple (i.e. `'\n', ''`).
231
+ * **Example:** `['foo', 'bold 10px sans-serif', ' bar', 'italic 10px sans-serif', ' baz', '']` will yield "**foo** *bar* baz".
232
+ * **Note:** Rich text is not supported for the immediate rendering API.
233
+ */
234
+ "text-value"?: string | string[] | undefined;
235
+ /**
236
+ * Font style as CSS `font` value, see:
237
+ * https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/font. Default is `'10px sans-serif'`
238
+ */
239
+ "text-font"?: string | undefined;
240
+ /**
241
+ * When `text-placement` is set to `'line'`, allow a maximum angle between adjacent characters.
242
+ * The expected value is in radians, and the default is 45° (`Math.PI / 4`).
243
+ */
244
+ "text-max-angle"?: number | undefined;
245
+ /**
246
+ * Horizontal text offset in pixels. A positive will shift the text right.
247
+ */
248
+ "text-offset-x"?: number | undefined;
249
+ /**
250
+ * Vertical text offset in pixels. A positive will shift the text down.
251
+ */
252
+ "text-offset-y"?: number | undefined;
253
+ /**
254
+ * For polygon labels or when `placement` is set to `'line'`, allow text to exceed
255
+ * the width of the polygon at the label position or the length of the path that it follows.
256
+ */
257
+ "text-overflow"?: boolean | undefined;
258
+ /**
259
+ * Text placement.
260
+ */
261
+ "text-placement"?: import("./Text.js").TextPlacement | undefined;
262
+ /**
263
+ * Scale.
264
+ */
265
+ "text-scale"?: number | import("../size.js").Size | undefined;
266
+ /**
267
+ * Whether to rotate the text with the view.
268
+ */
269
+ "text-rotate-with-view"?: boolean | undefined;
270
+ /**
271
+ * Rotation in radians (positive rotation clockwise).
272
+ */
273
+ "text-rotation"?: number | undefined;
274
+ /**
275
+ * Text alignment. Possible values: `'left'`, `'right'`, `'center'`, `'end'` or `'start'`.
276
+ * Default is `'center'` for `text-placement: 'point'`. For `text-placement: 'line'`, the default is to let the renderer choose a
277
+ * placement where `text-max-angle` is not exceeded.
278
+ */
279
+ "text-align"?: CanvasTextAlign | undefined;
280
+ /**
281
+ * Text justification within the text box.
282
+ * If not set, text is justified towards the `textAlign` anchor.
283
+ * Otherwise, use options `'left'`, `'center'`, or `'right'` to justify the text within the text box.
284
+ * **Note:** `text-justify` is ignored for immediate rendering and also for `text-placement: 'line'`.
285
+ */
286
+ "text-justify"?: import("./Text.js").TextJustify | undefined;
287
+ /**
288
+ * Text base line. Possible values: `'bottom'`, `'top'`, `'middle'`, `'alphabetic'`,
289
+ * `'hanging'`, `'ideographic'`.
290
+ */
291
+ "text-baseline"?: CanvasTextBaseline | undefined;
292
+ /**
293
+ * Padding in pixels around the text for decluttering and background. The order of
294
+ * values in the array is `[top, right, bottom, left]`.
295
+ */
296
+ "text-padding"?: number[] | undefined;
297
+ /**
298
+ * The fill color.
299
+ */
300
+ "text-fill-color"?: import("../color.js").Color | import("../colorlike.js").ColorLike | undefined;
301
+ /**
302
+ * The fill color.
303
+ */
304
+ "text-background-fill-color"?: import("../color.js").Color | import("../colorlike.js").ColorLike | undefined;
305
+ /**
306
+ * The stroke color.
307
+ */
308
+ "text-stroke-color"?: import("../color.js").Color | import("../colorlike.js").ColorLike | undefined;
309
+ /**
310
+ * Line cap style: `butt`, `round`, or `square`.
311
+ */
312
+ "text-stroke-line-cap"?: CanvasLineCap | undefined;
313
+ /**
314
+ * Line join style: `bevel`, `round`, or `miter`.
315
+ */
316
+ "text-stroke-line-join"?: CanvasLineJoin | undefined;
317
+ /**
318
+ * Line dash pattern.
319
+ */
320
+ "text-stroke-line-dash"?: number[] | undefined;
321
+ /**
322
+ * Line dash offset.
323
+ */
324
+ "text-stroke-line-dash-offset"?: number | undefined;
325
+ /**
326
+ * Miter limit.
327
+ */
328
+ "text-stroke-miter-limit"?: number | undefined;
329
+ /**
330
+ * Stroke pixel width.
331
+ */
332
+ "text-stroke-width"?: number | undefined;
333
+ /**
334
+ * The stroke color.
335
+ */
336
+ "text-background-stroke-color"?: import("../color.js").Color | import("../colorlike.js").ColorLike | undefined;
337
+ /**
338
+ * Line cap style: `butt`, `round`, or `square`.
339
+ */
340
+ "text-background-stroke-line-cap"?: CanvasLineCap | undefined;
341
+ /**
342
+ * Line join style: `bevel`, `round`, or `miter`.
343
+ */
344
+ "text-background-stroke-line-join"?: CanvasLineJoin | undefined;
345
+ /**
346
+ * Line dash pattern.
347
+ */
348
+ "text-background-stroke-line-dash"?: number[] | undefined;
349
+ /**
350
+ * Line dash offset.
351
+ */
352
+ "text-background-stroke-line-dash-offset"?: number | undefined;
353
+ /**
354
+ * Miter limit.
355
+ */
356
+ "text-background-stroke-miter-limit"?: number | undefined;
357
+ /**
358
+ * Stroke pixel width.
359
+ */
360
+ "text-background-stroke-width"?: number | undefined;
361
+ };
362
+ /**
363
+ * Icon style properties applied to point features. One of `icon-src` or `icon-img` must be provided to render
364
+ * points with an icon.
365
+ */
366
+ export type FlatIcon = {
367
+ /**
368
+ * Image source URI.
369
+ */
370
+ "icon-src"?: string | undefined;
371
+ /**
372
+ * Image object for the icon. If the `icon-src` option is not provided then the
373
+ * provided image must already be loaded. And in that case, it is required
374
+ * to provide the size of the image, with the `icon-img-size` option.
375
+ */
376
+ "icon-img"?: HTMLCanvasElement | HTMLImageElement | undefined;
377
+ /**
378
+ * Image size in pixels. Only required if `icon-img` is set and `icon-src` is not.
379
+ * The provided size needs to match the actual size of the image.
380
+ */
381
+ "icon-img-size"?: import("../size.js").Size | undefined;
382
+ /**
383
+ * Anchor. Default value is the icon center.
384
+ */
385
+ "icon-anchor"?: number[] | undefined;
386
+ /**
387
+ * Origin of the anchor: `bottom-left`, `bottom-right`,
388
+ * `top-left` or `top-right`.
389
+ */
390
+ "icon-anchor-origin"?: import("./Icon.js").IconOrigin | undefined;
391
+ /**
392
+ * Units in which the anchor x value is
393
+ * specified. A value of `'fraction'` indicates the x value is a fraction of the icon. A value of `'pixels'` indicates
394
+ * the x value in pixels.
395
+ */
396
+ "icon-anchor-x-units"?: import("./Icon.js").IconAnchorUnits | undefined;
397
+ /**
398
+ * Units in which the anchor y value is
399
+ * specified. A value of `'fraction'` indicates the y value is a fraction of the icon. A value of `'pixels'` indicates
400
+ * the y value in pixels.
401
+ */
402
+ "icon-anchor-y-units"?: import("./Icon.js").IconAnchorUnits | undefined;
403
+ /**
404
+ * Color to tint the icon. If not specified,
405
+ * the icon will be left as is.
406
+ */
407
+ "icon-color"?: string | import("../color.js").Color | undefined;
408
+ /**
409
+ * The `crossOrigin` attribute for loaded images. Note that you must provide a
410
+ * `icon-cross-origin` value if you want to access pixel data with the Canvas renderer.
411
+ * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
412
+ */
413
+ "icon-cross-origin"?: string | null | undefined;
414
+ /**
415
+ * Offset, which, together with the size and the offset origin, define the
416
+ * sub-rectangle to use from the original icon image.
417
+ */
418
+ "icon-offset"?: number[] | undefined;
419
+ /**
420
+ * Displacement of the icon.
421
+ */
422
+ "icon-displacement"?: number[] | undefined;
423
+ /**
424
+ * Origin of the offset: `bottom-left`, `bottom-right`,
425
+ * `top-left` or `top-right`.
426
+ */
427
+ "icon-offset-origin"?: import("./Icon.js").IconOrigin | undefined;
428
+ /**
429
+ * Opacity of the icon.
430
+ */
431
+ "icon-opacity"?: number | undefined;
432
+ /**
433
+ * Scale.
434
+ */
435
+ "icon-scale"?: number | import("../size.js").Size | undefined;
436
+ /**
437
+ * Rotation in radians (positive rotation clockwise).
438
+ */
439
+ "icon-rotation"?: number | undefined;
440
+ /**
441
+ * Whether to rotate the icon with the view.
442
+ */
443
+ "icon-rotate-with-view"?: boolean | undefined;
444
+ /**
445
+ * Icon size in pixel. Can be used together with `icon-offset` to define the
446
+ * sub-rectangle to use from the origin (sprite) icon image.
447
+ */
448
+ "icon-size"?: import("../size.js").Size | undefined;
449
+ /**
450
+ * Declutter mode
451
+ */
452
+ "icon-declutter-mode"?: "declutter" | "obstacle" | "none" | undefined;
453
+ };
454
+ /**
455
+ * Regular shape style properties for rendering point features. At least `shape-points` must be provided.
456
+ */
457
+ export type FlatShape = {
458
+ /**
459
+ * Number of points for stars and regular polygons. In case of a polygon, the number of points
460
+ * is the number of sides.
461
+ */
462
+ "shape-points"?: number | undefined;
463
+ /**
464
+ * The fill color.
465
+ */
466
+ "shape-fill-color"?: import("../color.js").Color | import("../colorlike.js").ColorLike | undefined;
467
+ /**
468
+ * The stroke color.
469
+ */
470
+ "shape-stroke-color"?: import("../color.js").Color | import("../colorlike.js").ColorLike | undefined;
471
+ /**
472
+ * Stroke pixel width.
473
+ */
474
+ "shape-stroke-width"?: number | undefined;
475
+ /**
476
+ * Line cap style: `butt`, `round`, or `square`.
477
+ */
478
+ "shape-stroke-line-cap"?: CanvasLineCap | undefined;
479
+ /**
480
+ * Line join style: `bevel`, `round`, or `miter`.
481
+ */
482
+ "shape-stroke-line-join"?: CanvasLineJoin | undefined;
483
+ /**
484
+ * Line dash pattern.
485
+ */
486
+ "shape-stroke-line-dash"?: number[] | undefined;
487
+ /**
488
+ * Line dash offset.
489
+ */
490
+ "shape-stroke-line-dash-offset"?: number | undefined;
491
+ /**
492
+ * Miter limit.
493
+ */
494
+ "shape-stroke-miter-limit"?: number | undefined;
495
+ /**
496
+ * Radius of a regular polygon.
497
+ */
498
+ "shape-radius"?: number | undefined;
499
+ /**
500
+ * First radius of a star. Ignored if radius is set.
501
+ */
502
+ "shape-radius1"?: number | undefined;
503
+ /**
504
+ * Second radius of a star.
505
+ */
506
+ "shape-radius2"?: number | undefined;
507
+ /**
508
+ * Shape's angle in radians. A value of 0 will have one of the shape's point facing up.
509
+ */
510
+ "shape-angle"?: number | undefined;
511
+ /**
512
+ * Displacement of the shape
513
+ */
514
+ "shape-displacement"?: number[] | undefined;
515
+ /**
516
+ * Rotation in radians (positive rotation clockwise).
517
+ */
518
+ "shape-rotation"?: number | undefined;
519
+ /**
520
+ * Whether to rotate the shape with the view.
521
+ */
522
+ "shape-rotate-with-view"?: boolean | undefined;
523
+ /**
524
+ * Scale. Unless two dimensional scaling is required a better
525
+ * result may be obtained with appropriate settings for `shape-radius`, `shape-radius1` and `shape-radius2`.
526
+ */
527
+ "shape-scale"?: number | import("../size.js").Size | undefined;
528
+ /**
529
+ * Declutter mode.
530
+ */
531
+ "shape-declutter-mode"?: "declutter" | "obstacle" | "none" | undefined;
532
+ };
533
+ /**
534
+ * Circle style properties for rendering point features. At least `circle-radius` must be provided.
535
+ */
536
+ export type FlatCircle = {
537
+ /**
538
+ * Circle radius.
539
+ */
540
+ "circle-radius"?: number | undefined;
541
+ /**
542
+ * The fill color.
543
+ */
544
+ "circle-fill-color"?: import("../color.js").Color | import("../colorlike.js").ColorLike | undefined;
545
+ /**
546
+ * The stroke color.
547
+ */
548
+ "circle-stroke-color"?: import("../color.js").Color | import("../colorlike.js").ColorLike | undefined;
549
+ /**
550
+ * Stroke pixel width.
551
+ */
552
+ "circle-stroke-width"?: number | undefined;
553
+ /**
554
+ * Line cap style: `butt`, `round`, or `square`.
555
+ */
556
+ "circle-stroke-line-cap"?: CanvasLineCap | undefined;
557
+ /**
558
+ * Line join style: `bevel`, `round`, or `miter`.
559
+ */
560
+ "circle-stroke-line-join"?: CanvasLineJoin | undefined;
561
+ /**
562
+ * Line dash pattern.
563
+ */
564
+ "circle-stroke-line-dash"?: number[] | undefined;
565
+ /**
566
+ * Line dash offset.
567
+ */
568
+ "circle-stroke-line-dash-offset"?: number | undefined;
569
+ /**
570
+ * Miter limit.
571
+ */
572
+ "circle-stroke-miter-limit"?: number | undefined;
573
+ /**
574
+ * displacement
575
+ */
576
+ "circle-displacement"?: number[] | undefined;
577
+ /**
578
+ * Scale. A two dimensional scale will produce an ellipse.
579
+ * Unless two dimensional scaling is required a better result may be obtained with an appropriate setting for `circle-radius`.
580
+ */
581
+ "circle-scale"?: number | import("../size.js").Size | undefined;
582
+ /**
583
+ * Rotation in radians
584
+ * (positive rotation clockwise, meaningful only when used in conjunction with a two dimensional scale).
585
+ */
586
+ "circle-rotation"?: number | undefined;
587
+ /**
588
+ * Whether to rotate the shape with the view
589
+ * (meaningful only when used in conjunction with a two dimensional scale).
590
+ */
591
+ "circle-rotate-with-view"?: boolean | undefined;
592
+ /**
593
+ * Declutter mode
594
+ */
595
+ "circle-declutter-mode"?: "declutter" | "obstacle" | "none" | undefined;
596
+ };
597
+ //# sourceMappingURL=flat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flat.d.ts","sourceRoot":"","sources":["flat.js"],"names":[],"mappings":"AAYA;;;;;;GAMG;AAEH;;;;GAIG;AAEH;;;;;GAKG;AAEH;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;GAGG;AACH,mCAHW,SAAS,GACR,OAAO,YAAY,EAAE,OAAO,CAWvC;;;;;wBArLY,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU;;;;4BAMpE,SAAS,GAAC,MAAM,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BA8GzB,WAAW,GAAC,UAAU,GAAC,MAAM,GAAC,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BA0BvC,WAAW,GAAC,UAAU,GAAC,MAAM,GAAC,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAuBvC,WAAW,GAAC,UAAU,GAAC,MAAM,GAAC,SAAS"}
package/style/flat.js ADDED
@@ -0,0 +1,341 @@
1
+ /**
2
+ * @module ol/style/flat
3
+ */
4
+
5
+ import Circle from '../style/Circle.js';
6
+ import Fill from './Fill.js';
7
+ import Icon from './Icon.js';
8
+ import RegularShape from './RegularShape.js';
9
+ import Stroke from './Stroke.js';
10
+ import Style from './Style.js';
11
+ import Text from './Text.js';
12
+
13
+ /**
14
+ * For static styling, the [layer.setStyle()]{@link module:ol/layer/Vector~VectorLayer#setStyle} method
15
+ * can be called with an object literal that has fill, stroke, text, icon, regular shape, and/or circle properties.
16
+ * @api
17
+ *
18
+ * @typedef {FlatFill & FlatStroke & FlatText & FlatIcon & FlatShape & FlatCircle} FlatStyle
19
+ */
20
+
21
+ /**
22
+ * A flat style literal or an array of the same.
23
+ *
24
+ * @typedef {FlatStyle|Array<FlatStyle>} FlatStyleLike
25
+ */
26
+
27
+ /**
28
+ * Fill style properties applied to polygon features.
29
+ *
30
+ * @typedef {Object} FlatFill
31
+ * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [fill-color] The fill color.
32
+ */
33
+
34
+ /**
35
+ * Stroke style properties applied to line strings and polygon boundaries. To apply a stroke, at least one of
36
+ * `stroke-color` or `stroke-width` must be provided.
37
+ *
38
+ * @typedef {Object} FlatStroke
39
+ * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [stroke-color] The stroke color.
40
+ * @property {number} [stroke-width] Stroke pixel width.
41
+ * @property {CanvasLineCap} [stroke-line-cap='round'] Line cap style: `butt`, `round`, or `square`.
42
+ * @property {CanvasLineJoin} [stroke-line-join='round'] Line join style: `bevel`, `round`, or `miter`.
43
+ * @property {Array<number>} [stroke-line-dash] Line dash pattern.
44
+ * @property {number} [stroke-line-dash-offset=0] Line dash offset.
45
+ * @property {number} [stroke-miter-limit=10] Miter limit.
46
+ */
47
+
48
+ /**
49
+ * Label style properties applied to all features. At a minimum, a `text-value` must be provided.
50
+ *
51
+ * @typedef {Object} FlatText
52
+ * @property {string|Array<string>} [text-value] Text content or rich text content. For plain text provide a string, which can
53
+ * contain line breaks (`\n`). For rich text provide an array of text/font tuples. A tuple consists of the text to
54
+ * render and the font to use (or `''` to use the text style's font). A line break has to be a separate tuple (i.e. `'\n', ''`).
55
+ * **Example:** `['foo', 'bold 10px sans-serif', ' bar', 'italic 10px sans-serif', ' baz', '']` will yield "**foo** *bar* baz".
56
+ * **Note:** Rich text is not supported for the immediate rendering API.
57
+ * @property {string} [text-font] Font style as CSS `font` value, see:
58
+ * https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/font. Default is `'10px sans-serif'`
59
+ * @property {number} [text-max-angle=Math.PI/4] When `text-placement` is set to `'line'`, allow a maximum angle between adjacent characters.
60
+ * The expected value is in radians, and the default is 45° (`Math.PI / 4`).
61
+ * @property {number} [text-offset-x=0] Horizontal text offset in pixels. A positive will shift the text right.
62
+ * @property {number} [text-offset-y=0] Vertical text offset in pixels. A positive will shift the text down.
63
+ * @property {boolean} [text-overflow=false] For polygon labels or when `placement` is set to `'line'`, allow text to exceed
64
+ * the width of the polygon at the label position or the length of the path that it follows.
65
+ * @property {import("./Text.js").TextPlacement} [text-placement='point'] Text placement.
66
+ * @property {number|import("../size.js").Size} [text-scale] Scale.
67
+ * @property {boolean} [text-rotate-with-view=false] Whether to rotate the text with the view.
68
+ * @property {number} [text-rotation=0] Rotation in radians (positive rotation clockwise).
69
+ * @property {CanvasTextAlign} [text-align] Text alignment. Possible values: `'left'`, `'right'`, `'center'`, `'end'` or `'start'`.
70
+ * Default is `'center'` for `text-placement: 'point'`. For `text-placement: 'line'`, the default is to let the renderer choose a
71
+ * placement where `text-max-angle` is not exceeded.
72
+ * @property {import('./Text.js').TextJustify} [text-justify] Text justification within the text box.
73
+ * If not set, text is justified towards the `textAlign` anchor.
74
+ * Otherwise, use options `'left'`, `'center'`, or `'right'` to justify the text within the text box.
75
+ * **Note:** `text-justify` is ignored for immediate rendering and also for `text-placement: 'line'`.
76
+ * @property {CanvasTextBaseline} [text-baseline='middle'] Text base line. Possible values: `'bottom'`, `'top'`, `'middle'`, `'alphabetic'`,
77
+ * `'hanging'`, `'ideographic'`.
78
+ * @property {Array<number>} [text-padding=[0, 0, 0, 0]] Padding in pixels around the text for decluttering and background. The order of
79
+ * values in the array is `[top, right, bottom, left]`.
80
+ * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [text-fill-color] The fill color.
81
+ * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [text-background-fill-color] The fill color.
82
+ * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [text-stroke-color] The stroke color.
83
+ * @property {CanvasLineCap} [text-stroke-line-cap='round'] Line cap style: `butt`, `round`, or `square`.
84
+ * @property {CanvasLineJoin} [text-stroke-line-join='round'] Line join style: `bevel`, `round`, or `miter`.
85
+ * @property {Array<number>} [text-stroke-line-dash] Line dash pattern.
86
+ * @property {number} [text-stroke-line-dash-offset=0] Line dash offset.
87
+ * @property {number} [text-stroke-miter-limit=10] Miter limit.
88
+ * @property {number} [text-stroke-width] Stroke pixel width.
89
+ * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [text-background-stroke-color] The stroke color.
90
+ * @property {CanvasLineCap} [text-background-stroke-line-cap='round'] Line cap style: `butt`, `round`, or `square`.
91
+ * @property {CanvasLineJoin} [text-background-stroke-line-join='round'] Line join style: `bevel`, `round`, or `miter`.
92
+ * @property {Array<number>} [text-background-stroke-line-dash] Line dash pattern.
93
+ * @property {number} [text-background-stroke-line-dash-offset=0] Line dash offset.
94
+ * @property {number} [text-background-stroke-miter-limit=10] Miter limit.
95
+ * @property {number} [text-background-stroke-width] Stroke pixel width.
96
+ */
97
+
98
+ /**
99
+ * Icon style properties applied to point features. One of `icon-src` or `icon-img` must be provided to render
100
+ * points with an icon.
101
+ *
102
+ * @typedef {Object} FlatIcon
103
+ * @property {string} [icon-src] Image source URI.
104
+ * @property {HTMLImageElement|HTMLCanvasElement} [icon-img] Image object for the icon. If the `icon-src` option is not provided then the
105
+ * provided image must already be loaded. And in that case, it is required
106
+ * to provide the size of the image, with the `icon-img-size` option.
107
+ * @property {import("../size.js").Size} [icon-img-size] Image size in pixels. Only required if `icon-img` is set and `icon-src` is not.
108
+ * The provided size needs to match the actual size of the image.
109
+ * @property {Array<number>} [icon-anchor=[0.5, 0.5]] Anchor. Default value is the icon center.
110
+ * @property {import("./Icon.js").IconOrigin} [icon-anchor-origin='top-left'] Origin of the anchor: `bottom-left`, `bottom-right`,
111
+ * `top-left` or `top-right`.
112
+ * @property {import("./Icon.js").IconAnchorUnits} [icon-anchor-x-units='fraction'] Units in which the anchor x value is
113
+ * specified. A value of `'fraction'` indicates the x value is a fraction of the icon. A value of `'pixels'` indicates
114
+ * the x value in pixels.
115
+ * @property {import("./Icon.js").IconAnchorUnits} [icon-anchor-y-units='fraction'] Units in which the anchor y value is
116
+ * specified. A value of `'fraction'` indicates the y value is a fraction of the icon. A value of `'pixels'` indicates
117
+ * the y value in pixels.
118
+ * @property {import("../color.js").Color|string} [icon-color] Color to tint the icon. If not specified,
119
+ * the icon will be left as is.
120
+ * @property {null|string} [icon-cross-origin] The `crossOrigin` attribute for loaded images. Note that you must provide a
121
+ * `icon-cross-origin` value if you want to access pixel data with the Canvas renderer.
122
+ * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.
123
+ * @property {Array<number>} [icon-offset=[0, 0]] Offset, which, together with the size and the offset origin, define the
124
+ * sub-rectangle to use from the original icon image.
125
+ * @property {Array<number>} [icon-displacement=[0,0]] Displacement of the icon.
126
+ * @property {import("./Icon.js").IconOrigin} [icon-offset-origin='top-left'] Origin of the offset: `bottom-left`, `bottom-right`,
127
+ * `top-left` or `top-right`.
128
+ * @property {number} [icon-opacity=1] Opacity of the icon.
129
+ * @property {number|import("../size.js").Size} [icon-scale=1] Scale.
130
+ * @property {number} [icon-rotation=0] Rotation in radians (positive rotation clockwise).
131
+ * @property {boolean} [icon-rotate-with-view=false] Whether to rotate the icon with the view.
132
+ * @property {import("../size.js").Size} [icon-size] Icon size in pixel. Can be used together with `icon-offset` to define the
133
+ * sub-rectangle to use from the origin (sprite) icon image.
134
+ * @property {"declutter"|"obstacle"|"none"|undefined} [icon-declutter-mode] Declutter mode
135
+ */
136
+
137
+ /**
138
+ * Regular shape style properties for rendering point features. At least `shape-points` must be provided.
139
+ *
140
+ * @typedef {Object} FlatShape
141
+ * @property {number} [shape-points] Number of points for stars and regular polygons. In case of a polygon, the number of points
142
+ * is the number of sides.
143
+ * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [shape-fill-color] The fill color.
144
+ * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [shape-stroke-color] The stroke color.
145
+ * @property {number} [shape-stroke-width] Stroke pixel width.
146
+ * @property {CanvasLineCap} [shape-stroke-line-cap='round'] Line cap style: `butt`, `round`, or `square`.
147
+ * @property {CanvasLineJoin} [shape-stroke-line-join='round'] Line join style: `bevel`, `round`, or `miter`.
148
+ * @property {Array<number>} [shape-stroke-line-dash] Line dash pattern.
149
+ * @property {number} [shape-stroke-line-dash-offset=0] Line dash offset.
150
+ * @property {number} [shape-stroke-miter-limit=10] Miter limit.
151
+ * @property {number} [shape-radius] Radius of a regular polygon.
152
+ * @property {number} [shape-radius1] First radius of a star. Ignored if radius is set.
153
+ * @property {number} [shape-radius2] Second radius of a star.
154
+ * @property {number} [shape-angle=0] Shape's angle in radians. A value of 0 will have one of the shape's point facing up.
155
+ * @property {Array<number>} [shape-displacement=[0,0]] Displacement of the shape
156
+ * @property {number} [shape-rotation=0] Rotation in radians (positive rotation clockwise).
157
+ * @property {boolean} [shape-rotate-with-view=false] Whether to rotate the shape with the view.
158
+ * @property {number|import("../size.js").Size} [shape-scale=1] Scale. Unless two dimensional scaling is required a better
159
+ * result may be obtained with appropriate settings for `shape-radius`, `shape-radius1` and `shape-radius2`.
160
+ * @property {"declutter"|"obstacle"|"none"|undefined} [shape-declutter-mode] Declutter mode.
161
+ */
162
+
163
+ /**
164
+ * Circle style properties for rendering point features. At least `circle-radius` must be provided.
165
+ *
166
+ * @typedef {Object} FlatCircle
167
+ * @property {number} [circle-radius] Circle radius.
168
+ * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [circle-fill-color] The fill color.
169
+ * @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [circle-stroke-color] The stroke color.
170
+ * @property {number} [circle-stroke-width] Stroke pixel width.
171
+ * @property {CanvasLineCap} [circle-stroke-line-cap='round'] Line cap style: `butt`, `round`, or `square`.
172
+ * @property {CanvasLineJoin} [circle-stroke-line-join='round'] Line join style: `bevel`, `round`, or `miter`.
173
+ * @property {Array<number>} [circle-stroke-line-dash] Line dash pattern.
174
+ * @property {number} [circle-stroke-line-dash-offset=0] Line dash offset.
175
+ * @property {number} [circle-stroke-miter-limit=10] Miter limit.
176
+ * @property {Array<number>} [circle-displacement=[0,0]] displacement
177
+ * @property {number|import("../size.js").Size} [circle-scale=1] Scale. A two dimensional scale will produce an ellipse.
178
+ * Unless two dimensional scaling is required a better result may be obtained with an appropriate setting for `circle-radius`.
179
+ * @property {number} [circle-rotation=0] Rotation in radians
180
+ * (positive rotation clockwise, meaningful only when used in conjunction with a two dimensional scale).
181
+ * @property {boolean} [circle-rotate-with-view=false] Whether to rotate the shape with the view
182
+ * (meaningful only when used in conjunction with a two dimensional scale).
183
+ * @property {"declutter"|"obstacle"|"none"|undefined} [circle-declutter-mode] Declutter mode
184
+ */
185
+
186
+ /**
187
+ * @param {FlatStyle} flatStyle A flat style literal.
188
+ * @return {import("./Style.js").default} A style instance.
189
+ */
190
+ export function toStyle(flatStyle) {
191
+ const style = new Style({
192
+ fill: getFill(flatStyle, ''),
193
+ stroke: getStroke(flatStyle, ''),
194
+ text: getText(flatStyle),
195
+ image: getImage(flatStyle),
196
+ });
197
+
198
+ return style;
199
+ }
200
+
201
+ /**
202
+ * @param {FlatStyle} flatStyle The flat style.
203
+ * @param {string} prefix The property prefix.
204
+ * @return {Fill|undefined} The fill (if any).
205
+ */
206
+ function getFill(flatStyle, prefix) {
207
+ const color = flatStyle[prefix + 'fill-color'];
208
+ if (!color) {
209
+ return;
210
+ }
211
+
212
+ return new Fill({color: color});
213
+ }
214
+
215
+ /**
216
+ * @param {FlatStyle} flatStyle The flat style.
217
+ * @param {string} prefix The property prefix.
218
+ * @return {Stroke|undefined} The stroke (if any).
219
+ */
220
+ function getStroke(flatStyle, prefix) {
221
+ const width = flatStyle[prefix + 'stroke-width'];
222
+ const color = flatStyle[prefix + 'stroke-color'];
223
+ if (!width && !color) {
224
+ return;
225
+ }
226
+
227
+ return new Stroke({
228
+ width: width,
229
+ color: color,
230
+ lineCap: flatStyle[prefix + 'stroke-line-cap'],
231
+ lineJoin: flatStyle[prefix + 'stroke-line-join'],
232
+ lineDash: flatStyle[prefix + 'stroke-line-dash'],
233
+ lineDashOffset: flatStyle[prefix + 'stroke-line-dash-offset'],
234
+ miterLimit: flatStyle[prefix + 'stroke-miter-limit'],
235
+ });
236
+ }
237
+
238
+ /**
239
+ * @param {FlatStyle} flatStyle The flat style.
240
+ * @return {Text|undefined} The text (if any).
241
+ */
242
+ function getText(flatStyle) {
243
+ const value = flatStyle['text-value'];
244
+ if (!value) {
245
+ return;
246
+ }
247
+
248
+ const text = new Text({
249
+ text: value,
250
+ font: flatStyle['text-font'],
251
+ maxAngle: flatStyle['text-max-angle'],
252
+ offsetX: flatStyle['text-offset-x'],
253
+ offsetY: flatStyle['text-offset-y'],
254
+ overflow: flatStyle['text-overflow'],
255
+ placement: flatStyle['text-placement'],
256
+ scale: flatStyle['text-scale'],
257
+ rotateWithView: flatStyle['text-rotate-with-view'],
258
+ rotation: flatStyle['text-rotation'],
259
+ textAlign: flatStyle['text-align'],
260
+ justify: flatStyle['text-justify'],
261
+ textBaseline: flatStyle['text-baseline'],
262
+ padding: flatStyle['text-padding'],
263
+ fill: getFill(flatStyle, 'text-'),
264
+ backgroundFill: getFill(flatStyle, 'text-background-'),
265
+ stroke: getStroke(flatStyle, 'text-'),
266
+ backgroundStroke: getStroke(flatStyle, 'text-background-'),
267
+ });
268
+
269
+ return text;
270
+ }
271
+
272
+ /**
273
+ * @param {FlatStyle} flatStyle The flat style.
274
+ * @return {import("./Image.js").default|undefined} The image (if any).
275
+ */
276
+ function getImage(flatStyle) {
277
+ const iconSrc = flatStyle['icon-src'];
278
+ const iconImg = flatStyle['icon-img'];
279
+ if (iconSrc || iconImg) {
280
+ const icon = new Icon({
281
+ src: iconSrc,
282
+ img: iconImg,
283
+ imgSize: flatStyle['icon-img-size'],
284
+ anchor: flatStyle['icon-anchor'],
285
+ anchorOrigin: flatStyle['icon-anchor-origin'],
286
+ anchorXUnits: flatStyle['icon-anchor-x-units'],
287
+ anchorYUnits: flatStyle['icon-anchor-y-units'],
288
+ color: flatStyle['icon-color'],
289
+ crossOrigin: flatStyle['icon-cross-origin'],
290
+ offset: flatStyle['icon-offset'],
291
+ displacement: flatStyle['icon-displacement'],
292
+ opacity: flatStyle['icon-opacity'],
293
+ scale: flatStyle['icon-scale'],
294
+ rotation: flatStyle['icon-rotation'],
295
+ rotateWithView: flatStyle['icon-rotate-with-view'],
296
+ size: flatStyle['icon-size'],
297
+ declutterMode: flatStyle['icon-declutter-mode'],
298
+ });
299
+ return icon;
300
+ }
301
+
302
+ const shapePoints = flatStyle['shape-points'];
303
+ if (shapePoints) {
304
+ const prefix = 'shape-';
305
+ const shape = new RegularShape({
306
+ points: shapePoints,
307
+ fill: getFill(flatStyle, prefix),
308
+ stroke: getStroke(flatStyle, prefix),
309
+ radius: flatStyle['shape-radius'],
310
+ radius1: flatStyle['shape-radius1'],
311
+ radius2: flatStyle['shape-radius2'],
312
+ angle: flatStyle['shape-angle'],
313
+ displacement: flatStyle['shape-displacement'],
314
+ rotation: flatStyle['shape-rotation'],
315
+ rotateWithView: flatStyle['shape-rotate-with-view'],
316
+ scale: flatStyle['shape-scale'],
317
+ declutterMode: flatStyle['shape-declutter-mode'],
318
+ });
319
+
320
+ return shape;
321
+ }
322
+
323
+ const circleRadius = flatStyle['circle-radius'];
324
+ if (circleRadius) {
325
+ const prefix = 'circle-';
326
+ const circle = new Circle({
327
+ radius: circleRadius,
328
+ fill: getFill(flatStyle, prefix),
329
+ stroke: getStroke(flatStyle, prefix),
330
+ displacement: flatStyle['circle-displacement'],
331
+ scale: flatStyle['circle-scale'],
332
+ rotation: flatStyle['circle-rotation'],
333
+ rotateWithView: flatStyle['circle-rotate-with-view'],
334
+ declutterMode: flatStyle['circle-declutter-mode'],
335
+ });
336
+
337
+ return circle;
338
+ }
339
+
340
+ return;
341
+ }