ol 7.2.3-dev.1672687369921 → 7.2.3-dev.1672696068643
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/dist/ol.js +2 -2
- package/dist/ol.js.map +1 -1
- package/geom/flat/linechunk.d.ts +11 -0
- package/geom/flat/linechunk.d.ts.map +1 -0
- package/geom/flat/linechunk.js +57 -0
- package/package.json +1 -1
- package/render/canvas/TextBuilder.d.ts.map +1 -1
- package/render/canvas/TextBuilder.js +32 -14
- package/render/canvas.d.ts +5 -0
- package/render/canvas.d.ts.map +1 -1
- package/render/canvas.js +1 -0
- package/style/Text.d.ts +24 -0
- package/style/Text.d.ts.map +1 -1
- package/style/Text.js +27 -0
- package/style/flat.d.ts +7 -0
- package/style/flat.d.ts.map +1 -1
- package/style/flat.js +3 -0
- package/util.js +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates chunks of equal length from a linestring
|
|
3
|
+
* @param {number} chunkLength Length of each chunk.
|
|
4
|
+
* @param {Array<number>} flatCoordinates Flat coordinates.
|
|
5
|
+
* @param {number} offset Start offset of the `flatCoordinates`.
|
|
6
|
+
* @param {number} end End offset of the `flatCoordinates`.
|
|
7
|
+
* @param {number} stride Stride.
|
|
8
|
+
* @return {Array<Array<number>>} Chunks of linestrings with stride 2.
|
|
9
|
+
*/
|
|
10
|
+
export function lineChunk(chunkLength: number, flatCoordinates: Array<number>, offset: number, end: number, stride: number): Array<Array<number>>;
|
|
11
|
+
//# sourceMappingURL=linechunk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linechunk.d.ts","sourceRoot":"","sources":["linechunk.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,uCAPW,MAAM,mBACN,MAAM,MAAM,CAAC,UACb,MAAM,OACN,MAAM,UACN,MAAM,GACL,MAAM,MAAM,MAAM,CAAC,CAAC,CA+C/B"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {lerp} from '../../math.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates chunks of equal length from a linestring
|
|
5
|
+
* @param {number} chunkLength Length of each chunk.
|
|
6
|
+
* @param {Array<number>} flatCoordinates Flat coordinates.
|
|
7
|
+
* @param {number} offset Start offset of the `flatCoordinates`.
|
|
8
|
+
* @param {number} end End offset of the `flatCoordinates`.
|
|
9
|
+
* @param {number} stride Stride.
|
|
10
|
+
* @return {Array<Array<number>>} Chunks of linestrings with stride 2.
|
|
11
|
+
*/
|
|
12
|
+
export function lineChunk(chunkLength, flatCoordinates, offset, end, stride) {
|
|
13
|
+
const chunks = [];
|
|
14
|
+
let cursor = offset;
|
|
15
|
+
let chunkM = 0;
|
|
16
|
+
let currentChunk = flatCoordinates.slice(offset, 2);
|
|
17
|
+
while (chunkM < chunkLength && cursor + stride < end) {
|
|
18
|
+
const [x1, y1] = currentChunk.slice(-2);
|
|
19
|
+
const x2 = flatCoordinates[cursor + stride];
|
|
20
|
+
const y2 = flatCoordinates[cursor + stride + 1];
|
|
21
|
+
const segmentLength = Math.sqrt(
|
|
22
|
+
(x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)
|
|
23
|
+
);
|
|
24
|
+
chunkM += segmentLength;
|
|
25
|
+
if (chunkM >= chunkLength) {
|
|
26
|
+
const m = (chunkLength - chunkM + segmentLength) / segmentLength;
|
|
27
|
+
const x = lerp(x1, x2, m);
|
|
28
|
+
const y = lerp(y1, y2, m);
|
|
29
|
+
currentChunk.push(x, y);
|
|
30
|
+
chunks.push(currentChunk);
|
|
31
|
+
currentChunk = [x, y];
|
|
32
|
+
if (chunkM == chunkLength) {
|
|
33
|
+
cursor += stride;
|
|
34
|
+
}
|
|
35
|
+
chunkM = 0;
|
|
36
|
+
} else if (chunkM < chunkLength) {
|
|
37
|
+
currentChunk.push(
|
|
38
|
+
flatCoordinates[cursor + stride],
|
|
39
|
+
flatCoordinates[cursor + stride + 1]
|
|
40
|
+
);
|
|
41
|
+
cursor += stride;
|
|
42
|
+
} else {
|
|
43
|
+
const missing = segmentLength - chunkM;
|
|
44
|
+
const x = lerp(x1, x2, missing / segmentLength);
|
|
45
|
+
const y = lerp(y1, y2, missing / segmentLength);
|
|
46
|
+
currentChunk.push(x, y);
|
|
47
|
+
chunks.push(currentChunk);
|
|
48
|
+
currentChunk = [x, y];
|
|
49
|
+
chunkM = 0;
|
|
50
|
+
cursor += stride;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (chunkM > 0) {
|
|
54
|
+
chunks.push(currentChunk);
|
|
55
|
+
}
|
|
56
|
+
return chunks;
|
|
57
|
+
}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextBuilder.d.ts","sourceRoot":"","sources":["TextBuilder.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TextBuilder.d.ts","sourceRoot":"","sources":["TextBuilder.js"],"names":[],"mappings":"yBA2BU,MAAM;;;;;;;;;;;;;;;AAgBhB;IAUI;;;OAGG;IACH,gBAAmB;IAEnB;;;OAGG;IACH,cAAe;IAEf;;;OAGG;IACH,qBAAqB;IAErB;;;OAGG;IACH,qBAAqB;IAErB;;;OAGG;IACH,4BAAoC;IAEpC;;;OAGG;IACH,sBAAsB;IAEtB;;;OAGG;IACH,uBAA0B;IAE1B;;OAEG;IACH;YAFkB,MAAM,GAAE,OAAO,cAAc,EAAE,SAAS;MAEtC;IAEpB;;;OAGG;IACH,yBAA4B;IAE5B;;OAEG;IACH;YAFkB,MAAM,GAAE,OAAO,cAAc,EAAE,WAAW;MAEtC;IAEtB;;;OAGG;IACH,mBAAsE;IAEtE;;OAEG;IACH;YAFkB,MAAM,GAAE,OAAO,cAAc,EAAE,SAAS;MAEtC;IAEpB;;;OAGG;IACH,iBAAkB;IAElB;;;OAGG;IACH,iBAAkB;IAElB;;;OAGG;IACH,mBAAoB;IAEpB;;;;OAIG;IACH,gCAAwC;IAwS1C;;OAEG;IACH,wBAqCC;IAED;;;;OAIG;IACH,mBAkDC;IAED;;;OAGG;IACH,wBAHW,OAAO,qBAAqB,EAAE,OAAO,0BA4G/C;CACF"}
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
} from '../canvas.js';
|
|
22
22
|
import {getUid} from '../../util.js';
|
|
23
23
|
import {intersects} from '../../extent.js';
|
|
24
|
+
import {lineChunk} from '../../geom/flat/linechunk.js';
|
|
24
25
|
import {matchingChunk} from '../../geom/flat/straightchunk.js';
|
|
25
26
|
/**
|
|
26
27
|
* @const
|
|
@@ -208,31 +209,46 @@ class CanvasTextBuilder extends CanvasBuilder {
|
|
|
208
209
|
}
|
|
209
210
|
}
|
|
210
211
|
this.beginGeometry(geometry, feature);
|
|
211
|
-
const
|
|
212
|
+
const repeat = textState.repeat;
|
|
213
|
+
const textAlign = repeat ? undefined : textState.textAlign;
|
|
212
214
|
// No `justify` support for line placement.
|
|
213
215
|
let flatOffset = 0;
|
|
214
|
-
let flatEnd;
|
|
215
216
|
for (let o = 0, oo = ends.length; o < oo; ++o) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
217
|
+
let chunks;
|
|
218
|
+
if (repeat) {
|
|
219
|
+
chunks = lineChunk(
|
|
220
|
+
repeat * this.resolution,
|
|
219
221
|
flatCoordinates,
|
|
220
222
|
flatOffset,
|
|
221
223
|
ends[o],
|
|
222
224
|
stride
|
|
223
225
|
);
|
|
224
|
-
flatOffset = range[0];
|
|
225
|
-
flatEnd = range[1];
|
|
226
226
|
} else {
|
|
227
|
-
|
|
227
|
+
chunks = [flatCoordinates.slice(flatOffset, ends[o])];
|
|
228
228
|
}
|
|
229
|
-
for (let
|
|
230
|
-
|
|
229
|
+
for (let c = 0, cc = chunks.length; c < cc; ++c) {
|
|
230
|
+
const chunk = chunks[c];
|
|
231
|
+
let chunkBegin = 0;
|
|
232
|
+
let chunkEnd = chunk.length;
|
|
233
|
+
if (textAlign == undefined) {
|
|
234
|
+
const range = matchingChunk(
|
|
235
|
+
textState.maxAngle,
|
|
236
|
+
chunk,
|
|
237
|
+
0,
|
|
238
|
+
chunk.length,
|
|
239
|
+
2
|
|
240
|
+
);
|
|
241
|
+
chunkBegin = range[0];
|
|
242
|
+
chunkEnd = range[1];
|
|
243
|
+
}
|
|
244
|
+
for (let i = chunkBegin; i < chunkEnd; i += stride) {
|
|
245
|
+
coordinates.push(chunk[i], chunk[i + 1]);
|
|
246
|
+
}
|
|
247
|
+
const end = coordinates.length;
|
|
248
|
+
flatOffset = ends[o];
|
|
249
|
+
this.drawChars_(begin, end);
|
|
250
|
+
begin = end;
|
|
231
251
|
}
|
|
232
|
-
const end = coordinates.length;
|
|
233
|
-
flatOffset = ends[o];
|
|
234
|
-
this.drawChars_(begin, end);
|
|
235
|
-
begin = end;
|
|
236
252
|
}
|
|
237
253
|
this.endGeometry(feature);
|
|
238
254
|
} else {
|
|
@@ -583,6 +599,7 @@ class CanvasTextBuilder extends CanvasBuilder {
|
|
|
583
599
|
textState.maxAngle = textStyle.getMaxAngle();
|
|
584
600
|
textState.placement = textStyle.getPlacement();
|
|
585
601
|
textState.textAlign = textStyle.getTextAlign();
|
|
602
|
+
textState.repeat = textStyle.getRepeat();
|
|
586
603
|
textState.justify = textStyle.getJustify();
|
|
587
604
|
textState.textBaseline =
|
|
588
605
|
textStyle.getTextBaseline() || defaultTextBaseline;
|
|
@@ -620,6 +637,7 @@ class CanvasTextBuilder extends CanvasBuilder {
|
|
|
620
637
|
textState.font +
|
|
621
638
|
textState.scale +
|
|
622
639
|
(textState.textAlign || '?') +
|
|
640
|
+
(textState.repeat || '?') +
|
|
623
641
|
(textState.justify || '?') +
|
|
624
642
|
(textState.textBaseline || '?');
|
|
625
643
|
this.fillKey_ = fillState
|
package/render/canvas.d.ts
CHANGED
|
@@ -94,6 +94,7 @@ export function drawImageOrLabel(context: CanvasRenderingContext2D, transform: i
|
|
|
94
94
|
* @typedef {Object} TextState
|
|
95
95
|
* @property {string} font Font.
|
|
96
96
|
* @property {CanvasTextAlign} [textAlign] TextAlign.
|
|
97
|
+
* @property {number} [repeat] Repeat.
|
|
97
98
|
* @property {import("../style/Text.js").TextJustify} [justify] Justify.
|
|
98
99
|
* @property {CanvasTextBaseline} textBaseline TextBaseline.
|
|
99
100
|
* @property {import("../style/Text.js").TextPlacement} [placement] Placement.
|
|
@@ -318,6 +319,10 @@ export type TextState = {
|
|
|
318
319
|
* TextAlign.
|
|
319
320
|
*/
|
|
320
321
|
textAlign?: CanvasTextAlign | undefined;
|
|
322
|
+
/**
|
|
323
|
+
* Repeat.
|
|
324
|
+
*/
|
|
325
|
+
repeat?: number | undefined;
|
|
321
326
|
/**
|
|
322
327
|
* Justify.
|
|
323
328
|
*/
|
package/render/canvas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas.d.ts","sourceRoot":"","sources":["canvas.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"canvas.d.ts","sourceRoot":"","sources":["canvas.js"],"names":[],"mappings":"AA+UA;;;;GAIG;AACH,uCAJW,MAAM,QACN,MAAM,GACL,MAAM,CAIjB;AAED;;;;;;GAMG;AACH,+CALW,MAAM,QACN,MAAM;QACC,MAAM,GAAE,MAAM;IACpB,MAAM,CAWjB;AAED;;;;GAIG;AACH,6CAJW,SAAS,UACT,MAAM,MAAM,CAAC;WACJ,MAAM;YAAU,MAAM;YAAU,MAAM,MAAM,CAAC;aAAW,MAAM,MAAM,CAAC;gBAAc,MAAM,MAAM,CAAC;EA4BnH;AAED;;;;;GAKG;AACH,wCALW,wBAAwB,YACxB,MAAM,WACN,MAAM,WACN,MAAM,QAQhB;AAED;;;;;;;;;;;;GAYG;AACH,0CAZW,wBAAwB,aACxB,OAAO,iBAAiB,EAAE,SAAS,GAAC,IAAI,WACxC,MAAM,gBACN,KAAK,GAAC,iBAAiB,GAAC,gBAAgB,GAAC,gBAAgB,WACzD,MAAM,WACN,MAAM,KAC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;;;;aASb,aAAa;;;;cACb,MAAM,MAAM,CAAC;;;;oBACb,MAAM;;;;cACN,cAAc;;;;eACd,MAAM;;;;gBACN,MAAM;;;;iBACN,OAAO,iBAAiB,EAAE,SAAS;;;;;;UAKnC,MAAM;;;;;;;;;;;;;;;;kBAIN,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAYlB,UAAQ;;;;8BACR,UAAQ;;;;iBACR,MAAM,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;QAOP,MAAM,GAAE,OAAO,sBAAsB,EAAE,sBAAsB"}
|
package/render/canvas.js
CHANGED
|
@@ -59,6 +59,7 @@ import {getFontParameters} from '../css.js';
|
|
|
59
59
|
* @typedef {Object} TextState
|
|
60
60
|
* @property {string} font Font.
|
|
61
61
|
* @property {CanvasTextAlign} [textAlign] TextAlign.
|
|
62
|
+
* @property {number} [repeat] Repeat.
|
|
62
63
|
* @property {import("../style/Text.js").TextJustify} [justify] Justify.
|
|
63
64
|
* @property {CanvasTextBaseline} textBaseline TextBaseline.
|
|
64
65
|
* @property {import("../style/Text.js").TextPlacement} [placement] Placement.
|
package/style/Text.d.ts
CHANGED
|
@@ -35,6 +35,11 @@ export type Options = {
|
|
|
35
35
|
* Text placement.
|
|
36
36
|
*/
|
|
37
37
|
placement?: TextPlacement | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Repeat interval in pixels. When set, the text will be repeated at this interval. Only available
|
|
40
|
+
* when `placement` is set to `'line'`. Overrides 'textAlign'.
|
|
41
|
+
*/
|
|
42
|
+
repeat?: number | undefined;
|
|
38
43
|
/**
|
|
39
44
|
* Scale.
|
|
40
45
|
*/
|
|
@@ -108,6 +113,8 @@ export type Options = {
|
|
|
108
113
|
* @property {boolean} [overflow=false] For polygon labels or when `placement` is set to `'line'`, allow text to exceed
|
|
109
114
|
* the width of the polygon at the label position or the length of the path that it follows.
|
|
110
115
|
* @property {TextPlacement} [placement='point'] Text placement.
|
|
116
|
+
* @property {number} [repeat] Repeat interval in pixels. When set, the text will be repeated at this interval. Only available
|
|
117
|
+
* when `placement` is set to `'line'`. Overrides 'textAlign'.
|
|
111
118
|
* @property {number|import("../size.js").Size} [scale] Scale.
|
|
112
119
|
* @property {boolean} [rotateWithView=false] Whether to rotate the text with the view.
|
|
113
120
|
* @property {number} [rotation=0] Rotation in radians (positive rotation clockwise).
|
|
@@ -184,6 +191,11 @@ declare class Text {
|
|
|
184
191
|
* @type {TextJustify|undefined}
|
|
185
192
|
*/
|
|
186
193
|
private justify_;
|
|
194
|
+
/**
|
|
195
|
+
* @private
|
|
196
|
+
* @type {number|undefined}
|
|
197
|
+
*/
|
|
198
|
+
private repeat_;
|
|
187
199
|
/**
|
|
188
200
|
* @private
|
|
189
201
|
* @type {CanvasTextBaseline|undefined}
|
|
@@ -269,6 +281,12 @@ declare class Text {
|
|
|
269
281
|
* @api
|
|
270
282
|
*/
|
|
271
283
|
getPlacement(): TextPlacement;
|
|
284
|
+
/**
|
|
285
|
+
* Get the repeat interval of the text.
|
|
286
|
+
* @return {number|undefined} Repeat interval in pixels.
|
|
287
|
+
* @api
|
|
288
|
+
*/
|
|
289
|
+
getRepeat(): number | undefined;
|
|
272
290
|
/**
|
|
273
291
|
* Get the x-offset for the text.
|
|
274
292
|
* @return {number} Horizontal text offset.
|
|
@@ -400,6 +418,12 @@ declare class Text {
|
|
|
400
418
|
* @api
|
|
401
419
|
*/
|
|
402
420
|
setPlacement(placement: TextPlacement): void;
|
|
421
|
+
/**
|
|
422
|
+
* Set the repeat interval of the text.
|
|
423
|
+
* @param {number|undefined} [repeat] Repeat interval in pixels.
|
|
424
|
+
* @api
|
|
425
|
+
*/
|
|
426
|
+
setRepeat(repeat?: number | undefined): void;
|
|
403
427
|
/**
|
|
404
428
|
* Set whether to rotate the text with the view.
|
|
405
429
|
*
|
package/style/Text.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["Text.js"],"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;;;;OAKG;IACH,cAHW,OAAO,WAAW,EAAE,OAAO,QAKrC;IAED;;;;;OAKG;IACH,sBAHW,MAAM,GAAC,SAAS,QAK1B;IAED;;;;;OAKG;IACH,gBAHW,MAAM,GAAC,OAAO,YAAY,EAAE,IAAI,GAAC,SAAS,QAMpD;IAED;;;;;OAKG;IACH,kBAHW,OAAO,aAAa,EAAE,OAAO,QAKvC;IAED;;;;;OAKG;IACH,cAHW,MAAM,GAAC,MAAM,MAAM,CAAC,GAAC,SAAS,QAKxC;IAED;;;;;OAKG;IACH,wBAHW,eAAe,GAAC,SAAS,QAKnC;IAED;;;;;OAKG;IACH,oBAHW,WAAW,GAAC,SAAS,QAK/B;IAED;;;;;OAKG;IACH,8BAHW,kBAAkB,GAAC,SAAS,QAKtC;IAED;;;;;OAKG;IACH,wBAHW,OAAO,WAAW,EAAE,OAAO,QAKrC;IAED;;;;;OAKG;IACH,4BAHW,OAAO,aAAa,EAAE,OAAO,QAKvC;IAED;;;;;OAKG;IACH,oBAHW,MAAM,MAAM,CAAC,GAAC,IAAI,QAK5B;CACF"}
|
package/style/Text.js
CHANGED
|
@@ -35,6 +35,8 @@ const DEFAULT_FILL_COLOR = '#333';
|
|
|
35
35
|
* @property {boolean} [overflow=false] For polygon labels or when `placement` is set to `'line'`, allow text to exceed
|
|
36
36
|
* the width of the polygon at the label position or the length of the path that it follows.
|
|
37
37
|
* @property {TextPlacement} [placement='point'] Text placement.
|
|
38
|
+
* @property {number} [repeat] Repeat interval in pixels. When set, the text will be repeated at this interval. Only available
|
|
39
|
+
* when `placement` is set to `'line'`. Overrides 'textAlign'.
|
|
38
40
|
* @property {number|import("../size.js").Size} [scale] Scale.
|
|
39
41
|
* @property {boolean} [rotateWithView=false] Whether to rotate the text with the view.
|
|
40
42
|
* @property {number} [rotation=0] Rotation in radians (positive rotation clockwise).
|
|
@@ -122,6 +124,12 @@ class Text {
|
|
|
122
124
|
*/
|
|
123
125
|
this.justify_ = options.justify;
|
|
124
126
|
|
|
127
|
+
/**
|
|
128
|
+
* @private
|
|
129
|
+
* @type {number|undefined}
|
|
130
|
+
*/
|
|
131
|
+
this.repeat_ = options.repeat;
|
|
132
|
+
|
|
125
133
|
/**
|
|
126
134
|
* @private
|
|
127
135
|
* @type {CanvasTextBaseline|undefined}
|
|
@@ -208,6 +216,7 @@ class Text {
|
|
|
208
216
|
return new Text({
|
|
209
217
|
font: this.getFont(),
|
|
210
218
|
placement: this.getPlacement(),
|
|
219
|
+
repeat: this.getRepeat(),
|
|
211
220
|
maxAngle: this.getMaxAngle(),
|
|
212
221
|
overflow: this.getOverflow(),
|
|
213
222
|
rotation: this.getRotation(),
|
|
@@ -267,6 +276,15 @@ class Text {
|
|
|
267
276
|
return this.placement_;
|
|
268
277
|
}
|
|
269
278
|
|
|
279
|
+
/**
|
|
280
|
+
* Get the repeat interval of the text.
|
|
281
|
+
* @return {number|undefined} Repeat interval in pixels.
|
|
282
|
+
* @api
|
|
283
|
+
*/
|
|
284
|
+
getRepeat() {
|
|
285
|
+
return this.repeat_;
|
|
286
|
+
}
|
|
287
|
+
|
|
270
288
|
/**
|
|
271
289
|
* Get the x-offset for the text.
|
|
272
290
|
* @return {number} Horizontal text offset.
|
|
@@ -461,6 +479,15 @@ class Text {
|
|
|
461
479
|
this.placement_ = placement;
|
|
462
480
|
}
|
|
463
481
|
|
|
482
|
+
/**
|
|
483
|
+
* Set the repeat interval of the text.
|
|
484
|
+
* @param {number|undefined} [repeat] Repeat interval in pixels.
|
|
485
|
+
* @api
|
|
486
|
+
*/
|
|
487
|
+
setRepeat(repeat) {
|
|
488
|
+
this.repeat_ = repeat;
|
|
489
|
+
}
|
|
490
|
+
|
|
464
491
|
/**
|
|
465
492
|
* Set whether to rotate the text with the view.
|
|
466
493
|
*
|
package/style/flat.d.ts
CHANGED
|
@@ -47,6 +47,8 @@
|
|
|
47
47
|
* @property {boolean} [text-overflow=false] For polygon labels or when `placement` is set to `'line'`, allow text to exceed
|
|
48
48
|
* the width of the polygon at the label position or the length of the path that it follows.
|
|
49
49
|
* @property {import("./Text.js").TextPlacement} [text-placement='point'] Text placement.
|
|
50
|
+
* @property {number} [text-repeat] Repeat interval in pixels. When set, the text will be repeated at this interval. Only available when
|
|
51
|
+
* `text-placement` is set to `'line'`. Overrides `text-align`.
|
|
50
52
|
* @property {number|import("../size.js").Size} [text-scale] Scale.
|
|
51
53
|
* @property {boolean} [text-rotate-with-view=false] Whether to rotate the text with the view.
|
|
52
54
|
* @property {number} [text-rotation=0] Rotation in radians (positive rotation clockwise).
|
|
@@ -259,6 +261,11 @@ export type FlatText = {
|
|
|
259
261
|
* Text placement.
|
|
260
262
|
*/
|
|
261
263
|
"text-placement"?: import("./Text.js").TextPlacement | undefined;
|
|
264
|
+
/**
|
|
265
|
+
* Repeat interval in pixels. When set, the text will be repeated at this interval. Only available when
|
|
266
|
+
* `text-placement` is set to `'line'`. Overrides `text-align`.
|
|
267
|
+
*/
|
|
268
|
+
"text-repeat"?: number | undefined;
|
|
262
269
|
/**
|
|
263
270
|
* Scale.
|
|
264
271
|
*/
|
package/style/flat.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flat.d.ts","sourceRoot":"","sources":["flat.js"],"names":[],"mappings":"AAYA;;;;;;GAMG;AAEH;;;;GAIG;AAEH;;;;;GAKG;AAEH;;;;;;;;;;;;GAYG;AAEH
|
|
1
|
+
{"version":3,"file":"flat.d.ts","sourceRoot":"","sources":["flat.js"],"names":[],"mappings":"AAYA;;;;;;GAMG;AAEH;;;;GAIG;AAEH;;;;;GAKG;AAEH;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;GAGG;AACH,mCAHW,SAAS,GACR,OAAO,YAAY,EAAE,OAAO,CAWvC;;;;;wBAvLY,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU;;;;4BAMpE,SAAS,GAAC,MAAM,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAgHzB,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
CHANGED
|
@@ -63,6 +63,8 @@ import Text from './Text.js';
|
|
|
63
63
|
* @property {boolean} [text-overflow=false] For polygon labels or when `placement` is set to `'line'`, allow text to exceed
|
|
64
64
|
* the width of the polygon at the label position or the length of the path that it follows.
|
|
65
65
|
* @property {import("./Text.js").TextPlacement} [text-placement='point'] Text placement.
|
|
66
|
+
* @property {number} [text-repeat] Repeat interval in pixels. When set, the text will be repeated at this interval. Only available when
|
|
67
|
+
* `text-placement` is set to `'line'`. Overrides `text-align`.
|
|
66
68
|
* @property {number|import("../size.js").Size} [text-scale] Scale.
|
|
67
69
|
* @property {boolean} [text-rotate-with-view=false] Whether to rotate the text with the view.
|
|
68
70
|
* @property {number} [text-rotation=0] Rotation in radians (positive rotation clockwise).
|
|
@@ -253,6 +255,7 @@ function getText(flatStyle) {
|
|
|
253
255
|
offsetY: flatStyle['text-offset-y'],
|
|
254
256
|
overflow: flatStyle['text-overflow'],
|
|
255
257
|
placement: flatStyle['text-placement'],
|
|
258
|
+
repeat: flatStyle['text-repeat'],
|
|
256
259
|
scale: flatStyle['text-scale'],
|
|
257
260
|
rotateWithView: flatStyle['text-rotate-with-view'],
|
|
258
261
|
rotation: flatStyle['text-rotation'],
|
package/util.js
CHANGED