@antv/l7-layers 2.11.5 → 2.11.6
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/es/core/BaseModel.d.ts +1 -1
- package/es/core/BaseModel.js +32 -13
- package/es/plugins/UpdateModelPlugin.js +5 -1
- package/es/point/models/text.d.ts +1 -1
- package/es/point/models/text.js +76 -35
- package/lib/core/BaseModel.js +32 -13
- package/lib/plugins/UpdateModelPlugin.js +5 -1
- package/lib/point/models/text.js +76 -35
- package/package.json +6 -6
package/es/core/BaseModel.d.ts
CHANGED
|
@@ -123,7 +123,7 @@ export default class BaseModel<ChildLayerStyleOptions = {}> implements ILayerMod
|
|
|
123
123
|
getDefaultStyle(): unknown;
|
|
124
124
|
getUninforms(): IModelUniform;
|
|
125
125
|
getAnimateUniforms(): IModelUniform;
|
|
126
|
-
needUpdate(): boolean
|
|
126
|
+
needUpdate(): Promise<boolean>;
|
|
127
127
|
buildModels(): Promise<IModel[]>;
|
|
128
128
|
initModels(): Promise<IModel[]>;
|
|
129
129
|
clearModels(refresh?: boolean): void;
|
package/es/core/BaseModel.js
CHANGED
|
@@ -429,19 +429,13 @@ var BaseModel = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
429
429
|
}
|
|
430
430
|
}, {
|
|
431
431
|
key: "needUpdate",
|
|
432
|
-
value: function needUpdate() {
|
|
433
|
-
return false;
|
|
434
|
-
} // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
435
|
-
|
|
436
|
-
}, {
|
|
437
|
-
key: "buildModels",
|
|
438
432
|
value: function () {
|
|
439
|
-
var
|
|
433
|
+
var _needUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
440
434
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
441
435
|
while (1) {
|
|
442
436
|
switch (_context.prev = _context.next) {
|
|
443
437
|
case 0:
|
|
444
|
-
|
|
438
|
+
return _context.abrupt("return", false);
|
|
445
439
|
|
|
446
440
|
case 1:
|
|
447
441
|
case "end":
|
|
@@ -451,17 +445,17 @@ var BaseModel = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
451
445
|
}, _callee);
|
|
452
446
|
}));
|
|
453
447
|
|
|
454
|
-
function
|
|
455
|
-
return
|
|
448
|
+
function needUpdate() {
|
|
449
|
+
return _needUpdate.apply(this, arguments);
|
|
456
450
|
}
|
|
457
451
|
|
|
458
|
-
return
|
|
452
|
+
return needUpdate;
|
|
459
453
|
}() // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
460
454
|
|
|
461
455
|
}, {
|
|
462
|
-
key: "
|
|
456
|
+
key: "buildModels",
|
|
463
457
|
value: function () {
|
|
464
|
-
var
|
|
458
|
+
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
465
459
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
466
460
|
while (1) {
|
|
467
461
|
switch (_context2.prev = _context2.next) {
|
|
@@ -476,6 +470,31 @@ var BaseModel = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
476
470
|
}, _callee2);
|
|
477
471
|
}));
|
|
478
472
|
|
|
473
|
+
function buildModels() {
|
|
474
|
+
return _buildModels.apply(this, arguments);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
return buildModels;
|
|
478
|
+
}() // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
479
|
+
|
|
480
|
+
}, {
|
|
481
|
+
key: "initModels",
|
|
482
|
+
value: function () {
|
|
483
|
+
var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
484
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
485
|
+
while (1) {
|
|
486
|
+
switch (_context3.prev = _context3.next) {
|
|
487
|
+
case 0:
|
|
488
|
+
throw new Error('Method not implemented.');
|
|
489
|
+
|
|
490
|
+
case 1:
|
|
491
|
+
case "end":
|
|
492
|
+
return _context3.stop();
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}, _callee3);
|
|
496
|
+
}));
|
|
497
|
+
|
|
479
498
|
function initModels() {
|
|
480
499
|
return _initModels.apply(this, arguments);
|
|
481
500
|
}
|
|
@@ -20,7 +20,11 @@ var UpdateModelPlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functio
|
|
|
20
20
|
layer.hooks.beforeRender.tap('UpdateModelPlugin', function () {
|
|
21
21
|
// 处理文本更新
|
|
22
22
|
if (layer.layerModel) {
|
|
23
|
-
layer.layerModel.needUpdate()
|
|
23
|
+
layer.layerModel.needUpdate().then(function (flag) {
|
|
24
|
+
if (flag) {
|
|
25
|
+
layer.renderLayers();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
24
28
|
}
|
|
25
29
|
});
|
|
26
30
|
layer.hooks.afterRender.tap('UpdateModelPlugin', function () {
|
|
@@ -24,7 +24,7 @@ export default class TextModel extends BaseModel {
|
|
|
24
24
|
getUninforms(): IModelUniform;
|
|
25
25
|
initModels(): Promise<IModel[]>;
|
|
26
26
|
buildModels(): Promise<IModel[]>;
|
|
27
|
-
needUpdate(): boolean
|
|
27
|
+
needUpdate(): Promise<boolean>;
|
|
28
28
|
clearModels(): void;
|
|
29
29
|
protected registerBuiltinAttributes(): void;
|
|
30
30
|
private bindEvent;
|
package/es/point/models/text.js
CHANGED
|
@@ -125,6 +125,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
125
125
|
strokeWidth = _ref2$strokeWidth === void 0 ? 0 : _ref2$strokeWidth,
|
|
126
126
|
_ref2$textAnchor = _ref2.textAnchor,
|
|
127
127
|
textAnchor = _ref2$textAnchor === void 0 ? 'center' : _ref2$textAnchor,
|
|
128
|
+
textOffset = _ref2.textOffset,
|
|
128
129
|
_ref2$textAllowOverla = _ref2.textAllowOverlap,
|
|
129
130
|
textAllowOverlap = _ref2$textAllowOverla === void 0 ? false : _ref2$textAllowOverla,
|
|
130
131
|
_ref2$halo = _ref2.halo,
|
|
@@ -145,7 +146,8 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
145
146
|
|
|
146
147
|
this.preTextStyle = {
|
|
147
148
|
textAnchor: textAnchor,
|
|
148
|
-
textAllowOverlap: textAllowOverlap
|
|
149
|
+
textAllowOverlap: textAllowOverlap,
|
|
150
|
+
textOffset: textOffset
|
|
149
151
|
};
|
|
150
152
|
|
|
151
153
|
if (this.dataTextureTest && this.dataTextureNeedUpdate({
|
|
@@ -202,7 +204,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
202
204
|
key: "initModels",
|
|
203
205
|
value: function () {
|
|
204
206
|
var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
205
|
-
var _ref3, _ref3$textAnchor, textAnchor, _ref3$textAllowOverla, textAllowOverlap;
|
|
207
|
+
var _ref3, _ref3$textAnchor, textAnchor, _ref3$textAllowOverla, textAllowOverlap, textOffset;
|
|
206
208
|
|
|
207
209
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
208
210
|
while (1) {
|
|
@@ -211,10 +213,11 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
211
213
|
// 绑定事件
|
|
212
214
|
this.bindEvent();
|
|
213
215
|
this.extent = this.textExtent();
|
|
214
|
-
_ref3 = this.layer.getLayerConfig(), _ref3$textAnchor = _ref3.textAnchor, textAnchor = _ref3$textAnchor === void 0 ? 'center' : _ref3$textAnchor, _ref3$textAllowOverla = _ref3.textAllowOverlap, textAllowOverlap = _ref3$textAllowOverla === void 0 ? true : _ref3$textAllowOverla;
|
|
216
|
+
_ref3 = this.layer.getLayerConfig(), _ref3$textAnchor = _ref3.textAnchor, textAnchor = _ref3$textAnchor === void 0 ? 'center' : _ref3$textAnchor, _ref3$textAllowOverla = _ref3.textAllowOverlap, textAllowOverlap = _ref3$textAllowOverla === void 0 ? true : _ref3$textAllowOverla, textOffset = _ref3.textOffset;
|
|
215
217
|
this.preTextStyle = {
|
|
216
218
|
textAnchor: textAnchor,
|
|
217
|
-
textAllowOverlap: textAllowOverlap
|
|
219
|
+
textAllowOverlap: textAllowOverlap,
|
|
220
|
+
textOffset: textOffset
|
|
218
221
|
};
|
|
219
222
|
_context2.next = 6;
|
|
220
223
|
return this.buildModels();
|
|
@@ -289,31 +292,70 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
289
292
|
}()
|
|
290
293
|
}, {
|
|
291
294
|
key: "needUpdate",
|
|
292
|
-
value: function
|
|
293
|
-
var
|
|
294
|
-
|
|
295
|
-
textAllowOverlap = _ref5$textAllowOverla === void 0 ? false : _ref5$textAllowOverla;
|
|
295
|
+
value: function () {
|
|
296
|
+
var _needUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
297
|
+
var _ref5, _ref5$textAllowOverla, textAllowOverlap, _ref5$textAnchor, textAnchor, textOffset, data, zoom, extent, flag;
|
|
296
298
|
|
|
297
|
-
|
|
299
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
300
|
+
while (1) {
|
|
301
|
+
switch (_context4.prev = _context4.next) {
|
|
302
|
+
case 0:
|
|
303
|
+
_ref5 = this.layer.getLayerConfig(), _ref5$textAllowOverla = _ref5.textAllowOverlap, textAllowOverlap = _ref5$textAllowOverla === void 0 ? false : _ref5$textAllowOverla, _ref5$textAnchor = _ref5.textAnchor, textAnchor = _ref5$textAnchor === void 0 ? 'center' : _ref5$textAnchor, textOffset = _ref5.textOffset;
|
|
304
|
+
data = this.layer.getEncodedData();
|
|
305
|
+
|
|
306
|
+
if (!(JSON.stringify(textOffset) !== JSON.stringify(this.preTextStyle.textOffset) || textAnchor !== this.preTextStyle.textAnchor)) {
|
|
307
|
+
_context4.next = 6;
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
_context4.next = 5;
|
|
312
|
+
return this.mapping();
|
|
313
|
+
|
|
314
|
+
case 5:
|
|
315
|
+
return _context4.abrupt("return", true);
|
|
316
|
+
|
|
317
|
+
case 6:
|
|
318
|
+
if (!(data.length < 5 || textAllowOverlap)) {
|
|
319
|
+
_context4.next = 8;
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
return _context4.abrupt("return", false);
|
|
324
|
+
|
|
325
|
+
case 8:
|
|
326
|
+
// textAllowOverlap 发生改变
|
|
327
|
+
zoom = this.mapService.getZoom();
|
|
328
|
+
extent = this.mapService.getBounds();
|
|
329
|
+
flag = boundsContains(this.extent, extent); // 文本不能压盖则进行过滤
|
|
330
|
+
|
|
331
|
+
if (!(Math.abs(this.currentZoom - zoom) > 1 || !flag || textAllowOverlap !== this.preTextStyle.textAllowOverlap)) {
|
|
332
|
+
_context4.next = 15;
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
298
335
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
return false;
|
|
302
|
-
} // textAllowOverlap 发生改变
|
|
336
|
+
_context4.next = 14;
|
|
337
|
+
return this.reBuildModel();
|
|
303
338
|
|
|
339
|
+
case 14:
|
|
340
|
+
return _context4.abrupt("return", true);
|
|
304
341
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
var flag = boundsContains(this.extent, extent); // 文本不能压盖则进行过滤
|
|
342
|
+
case 15:
|
|
343
|
+
return _context4.abrupt("return", false);
|
|
308
344
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
345
|
+
case 16:
|
|
346
|
+
case "end":
|
|
347
|
+
return _context4.stop();
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}, _callee4, this);
|
|
351
|
+
}));
|
|
352
|
+
|
|
353
|
+
function needUpdate() {
|
|
354
|
+
return _needUpdate.apply(this, arguments);
|
|
313
355
|
}
|
|
314
356
|
|
|
315
|
-
return
|
|
316
|
-
}
|
|
357
|
+
return needUpdate;
|
|
358
|
+
}()
|
|
317
359
|
}, {
|
|
318
360
|
key: "clearModels",
|
|
319
361
|
value: function clearModels() {
|
|
@@ -505,7 +547,8 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
505
547
|
_ref8$spacing = _ref8.spacing,
|
|
506
548
|
spacing = _ref8$spacing === void 0 ? 2 : _ref8$spacing,
|
|
507
549
|
_ref8$textAnchor = _ref8.textAnchor,
|
|
508
|
-
textAnchor = _ref8$textAnchor === void 0 ? 'center' : _ref8$textAnchor
|
|
550
|
+
textAnchor = _ref8$textAnchor === void 0 ? 'center' : _ref8$textAnchor,
|
|
551
|
+
textOffset = _ref8.textOffset;
|
|
509
552
|
|
|
510
553
|
var data = this.layer.getEncodedData();
|
|
511
554
|
this.glyphInfo = data.map(function (feature) {
|
|
@@ -513,11 +556,9 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
513
556
|
shape = _feature$shape === void 0 ? '' : _feature$shape,
|
|
514
557
|
id = feature.id,
|
|
515
558
|
_feature$size2 = feature.size,
|
|
516
|
-
size = _feature$size2 === void 0 ? 1 : _feature$size2
|
|
517
|
-
_feature$textOffset = feature.textOffset,
|
|
518
|
-
textOffset = _feature$textOffset === void 0 ? [0, 0] : _feature$textOffset;
|
|
559
|
+
size = _feature$size2 === void 0 ? 1 : _feature$size2;
|
|
519
560
|
var shaping = shapeText(shape.toString(), mapping, // @ts-ignore
|
|
520
|
-
size, textAnchor, 'left', spacing, textOffset, iconfont);
|
|
561
|
+
size, textAnchor, 'left', spacing, textOffset || feature.textOffset || [0, 0], iconfont);
|
|
521
562
|
var glyphQuads = getGlyphQuads(shaping, textOffset, false);
|
|
522
563
|
feature.shaping = shaping;
|
|
523
564
|
feature.glyphQuads = glyphQuads; // feature.centroid = calculteCentroid(coordinates);
|
|
@@ -640,16 +681,16 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
640
681
|
}, {
|
|
641
682
|
key: "reBuildModel",
|
|
642
683
|
value: function () {
|
|
643
|
-
var _reBuildModel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
684
|
+
var _reBuildModel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
644
685
|
var _ref10, _ref10$mask, mask, _ref10$maskInside, maskInside, model;
|
|
645
686
|
|
|
646
|
-
return _regeneratorRuntime.wrap(function
|
|
687
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
647
688
|
while (1) {
|
|
648
|
-
switch (
|
|
689
|
+
switch (_context5.prev = _context5.next) {
|
|
649
690
|
case 0:
|
|
650
691
|
_ref10 = this.layer.getLayerConfig(), _ref10$mask = _ref10.mask, mask = _ref10$mask === void 0 ? false : _ref10$mask, _ref10$maskInside = _ref10.maskInside, maskInside = _ref10$maskInside === void 0 ? true : _ref10$maskInside;
|
|
651
692
|
this.filterGlyphs();
|
|
652
|
-
|
|
693
|
+
_context5.next = 4;
|
|
653
694
|
return this.layer.buildLayerModel({
|
|
654
695
|
moduleName: 'pointText',
|
|
655
696
|
vertexShader: textVert,
|
|
@@ -663,16 +704,16 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
663
704
|
});
|
|
664
705
|
|
|
665
706
|
case 4:
|
|
666
|
-
model =
|
|
707
|
+
model = _context5.sent;
|
|
667
708
|
// TODO 渲染流程待修改
|
|
668
|
-
this.layer.models = [model];
|
|
709
|
+
this.layer.models = [model];
|
|
669
710
|
|
|
670
711
|
case 6:
|
|
671
712
|
case "end":
|
|
672
|
-
return
|
|
713
|
+
return _context5.stop();
|
|
673
714
|
}
|
|
674
715
|
}
|
|
675
|
-
},
|
|
716
|
+
}, _callee5, this);
|
|
676
717
|
}));
|
|
677
718
|
|
|
678
719
|
function reBuildModel() {
|
package/lib/core/BaseModel.js
CHANGED
|
@@ -448,19 +448,13 @@ var BaseModel = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
|
|
|
448
448
|
}
|
|
449
449
|
}, {
|
|
450
450
|
key: "needUpdate",
|
|
451
|
-
value: function needUpdate() {
|
|
452
|
-
return false;
|
|
453
|
-
} // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
454
|
-
|
|
455
|
-
}, {
|
|
456
|
-
key: "buildModels",
|
|
457
451
|
value: function () {
|
|
458
|
-
var
|
|
452
|
+
var _needUpdate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
459
453
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
460
454
|
while (1) {
|
|
461
455
|
switch (_context.prev = _context.next) {
|
|
462
456
|
case 0:
|
|
463
|
-
|
|
457
|
+
return _context.abrupt("return", false);
|
|
464
458
|
|
|
465
459
|
case 1:
|
|
466
460
|
case "end":
|
|
@@ -470,17 +464,17 @@ var BaseModel = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
|
|
|
470
464
|
}, _callee);
|
|
471
465
|
}));
|
|
472
466
|
|
|
473
|
-
function
|
|
474
|
-
return
|
|
467
|
+
function needUpdate() {
|
|
468
|
+
return _needUpdate.apply(this, arguments);
|
|
475
469
|
}
|
|
476
470
|
|
|
477
|
-
return
|
|
471
|
+
return needUpdate;
|
|
478
472
|
}() // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
479
473
|
|
|
480
474
|
}, {
|
|
481
|
-
key: "
|
|
475
|
+
key: "buildModels",
|
|
482
476
|
value: function () {
|
|
483
|
-
var
|
|
477
|
+
var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
484
478
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
485
479
|
while (1) {
|
|
486
480
|
switch (_context2.prev = _context2.next) {
|
|
@@ -495,6 +489,31 @@ var BaseModel = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
|
|
|
495
489
|
}, _callee2);
|
|
496
490
|
}));
|
|
497
491
|
|
|
492
|
+
function buildModels() {
|
|
493
|
+
return _buildModels.apply(this, arguments);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
return buildModels;
|
|
497
|
+
}() // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
498
|
+
|
|
499
|
+
}, {
|
|
500
|
+
key: "initModels",
|
|
501
|
+
value: function () {
|
|
502
|
+
var _initModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
503
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
504
|
+
while (1) {
|
|
505
|
+
switch (_context3.prev = _context3.next) {
|
|
506
|
+
case 0:
|
|
507
|
+
throw new Error('Method not implemented.');
|
|
508
|
+
|
|
509
|
+
case 1:
|
|
510
|
+
case "end":
|
|
511
|
+
return _context3.stop();
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}, _callee3);
|
|
515
|
+
}));
|
|
516
|
+
|
|
498
517
|
function initModels() {
|
|
499
518
|
return _initModels.apply(this, arguments);
|
|
500
519
|
}
|
|
@@ -32,7 +32,11 @@ _dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
|
|
|
32
32
|
layer.hooks.beforeRender.tap('UpdateModelPlugin', function () {
|
|
33
33
|
// 处理文本更新
|
|
34
34
|
if (layer.layerModel) {
|
|
35
|
-
layer.layerModel.needUpdate()
|
|
35
|
+
layer.layerModel.needUpdate().then(function (flag) {
|
|
36
|
+
if (flag) {
|
|
37
|
+
layer.renderLayers();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
36
40
|
}
|
|
37
41
|
});
|
|
38
42
|
layer.hooks.afterRender.tap('UpdateModelPlugin', function () {
|
package/lib/point/models/text.js
CHANGED
|
@@ -142,6 +142,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
142
142
|
strokeWidth = _ref2$strokeWidth === void 0 ? 0 : _ref2$strokeWidth,
|
|
143
143
|
_ref2$textAnchor = _ref2.textAnchor,
|
|
144
144
|
textAnchor = _ref2$textAnchor === void 0 ? 'center' : _ref2$textAnchor,
|
|
145
|
+
textOffset = _ref2.textOffset,
|
|
145
146
|
_ref2$textAllowOverla = _ref2.textAllowOverlap,
|
|
146
147
|
textAllowOverlap = _ref2$textAllowOverla === void 0 ? false : _ref2$textAllowOverla,
|
|
147
148
|
_ref2$halo = _ref2.halo,
|
|
@@ -162,7 +163,8 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
162
163
|
|
|
163
164
|
this.preTextStyle = {
|
|
164
165
|
textAnchor: textAnchor,
|
|
165
|
-
textAllowOverlap: textAllowOverlap
|
|
166
|
+
textAllowOverlap: textAllowOverlap,
|
|
167
|
+
textOffset: textOffset
|
|
166
168
|
};
|
|
167
169
|
|
|
168
170
|
if (this.dataTextureTest && this.dataTextureNeedUpdate({
|
|
@@ -219,7 +221,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
219
221
|
key: "initModels",
|
|
220
222
|
value: function () {
|
|
221
223
|
var _initModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
222
|
-
var _ref3, _ref3$textAnchor, textAnchor, _ref3$textAllowOverla, textAllowOverlap;
|
|
224
|
+
var _ref3, _ref3$textAnchor, textAnchor, _ref3$textAllowOverla, textAllowOverlap, textOffset;
|
|
223
225
|
|
|
224
226
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
225
227
|
while (1) {
|
|
@@ -228,10 +230,11 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
228
230
|
// 绑定事件
|
|
229
231
|
this.bindEvent();
|
|
230
232
|
this.extent = this.textExtent();
|
|
231
|
-
_ref3 = this.layer.getLayerConfig(), _ref3$textAnchor = _ref3.textAnchor, textAnchor = _ref3$textAnchor === void 0 ? 'center' : _ref3$textAnchor, _ref3$textAllowOverla = _ref3.textAllowOverlap, textAllowOverlap = _ref3$textAllowOverla === void 0 ? true : _ref3$textAllowOverla;
|
|
233
|
+
_ref3 = this.layer.getLayerConfig(), _ref3$textAnchor = _ref3.textAnchor, textAnchor = _ref3$textAnchor === void 0 ? 'center' : _ref3$textAnchor, _ref3$textAllowOverla = _ref3.textAllowOverlap, textAllowOverlap = _ref3$textAllowOverla === void 0 ? true : _ref3$textAllowOverla, textOffset = _ref3.textOffset;
|
|
232
234
|
this.preTextStyle = {
|
|
233
235
|
textAnchor: textAnchor,
|
|
234
|
-
textAllowOverlap: textAllowOverlap
|
|
236
|
+
textAllowOverlap: textAllowOverlap,
|
|
237
|
+
textOffset: textOffset
|
|
235
238
|
};
|
|
236
239
|
_context2.next = 6;
|
|
237
240
|
return this.buildModels();
|
|
@@ -306,31 +309,70 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
306
309
|
}()
|
|
307
310
|
}, {
|
|
308
311
|
key: "needUpdate",
|
|
309
|
-
value: function
|
|
310
|
-
var
|
|
311
|
-
|
|
312
|
-
textAllowOverlap = _ref5$textAllowOverla === void 0 ? false : _ref5$textAllowOverla;
|
|
312
|
+
value: function () {
|
|
313
|
+
var _needUpdate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
314
|
+
var _ref5, _ref5$textAllowOverla, textAllowOverlap, _ref5$textAnchor, textAnchor, textOffset, data, zoom, extent, flag;
|
|
313
315
|
|
|
314
|
-
|
|
316
|
+
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
317
|
+
while (1) {
|
|
318
|
+
switch (_context4.prev = _context4.next) {
|
|
319
|
+
case 0:
|
|
320
|
+
_ref5 = this.layer.getLayerConfig(), _ref5$textAllowOverla = _ref5.textAllowOverlap, textAllowOverlap = _ref5$textAllowOverla === void 0 ? false : _ref5$textAllowOverla, _ref5$textAnchor = _ref5.textAnchor, textAnchor = _ref5$textAnchor === void 0 ? 'center' : _ref5$textAnchor, textOffset = _ref5.textOffset;
|
|
321
|
+
data = this.layer.getEncodedData();
|
|
322
|
+
|
|
323
|
+
if (!(JSON.stringify(textOffset) !== JSON.stringify(this.preTextStyle.textOffset) || textAnchor !== this.preTextStyle.textAnchor)) {
|
|
324
|
+
_context4.next = 6;
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
_context4.next = 5;
|
|
329
|
+
return this.mapping();
|
|
330
|
+
|
|
331
|
+
case 5:
|
|
332
|
+
return _context4.abrupt("return", true);
|
|
333
|
+
|
|
334
|
+
case 6:
|
|
335
|
+
if (!(data.length < 5 || textAllowOverlap)) {
|
|
336
|
+
_context4.next = 8;
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
return _context4.abrupt("return", false);
|
|
341
|
+
|
|
342
|
+
case 8:
|
|
343
|
+
// textAllowOverlap 发生改变
|
|
344
|
+
zoom = this.mapService.getZoom();
|
|
345
|
+
extent = this.mapService.getBounds();
|
|
346
|
+
flag = (0, _l7Utils.boundsContains)(this.extent, extent); // 文本不能压盖则进行过滤
|
|
347
|
+
|
|
348
|
+
if (!(Math.abs(this.currentZoom - zoom) > 1 || !flag || textAllowOverlap !== this.preTextStyle.textAllowOverlap)) {
|
|
349
|
+
_context4.next = 15;
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
315
352
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
return false;
|
|
319
|
-
} // textAllowOverlap 发生改变
|
|
353
|
+
_context4.next = 14;
|
|
354
|
+
return this.reBuildModel();
|
|
320
355
|
|
|
356
|
+
case 14:
|
|
357
|
+
return _context4.abrupt("return", true);
|
|
321
358
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
var flag = (0, _l7Utils.boundsContains)(this.extent, extent); // 文本不能压盖则进行过滤
|
|
359
|
+
case 15:
|
|
360
|
+
return _context4.abrupt("return", false);
|
|
325
361
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
362
|
+
case 16:
|
|
363
|
+
case "end":
|
|
364
|
+
return _context4.stop();
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}, _callee4, this);
|
|
368
|
+
}));
|
|
369
|
+
|
|
370
|
+
function needUpdate() {
|
|
371
|
+
return _needUpdate.apply(this, arguments);
|
|
330
372
|
}
|
|
331
373
|
|
|
332
|
-
return
|
|
333
|
-
}
|
|
374
|
+
return needUpdate;
|
|
375
|
+
}()
|
|
334
376
|
}, {
|
|
335
377
|
key: "clearModels",
|
|
336
378
|
value: function clearModels() {
|
|
@@ -522,7 +564,8 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
522
564
|
_ref8$spacing = _ref8.spacing,
|
|
523
565
|
spacing = _ref8$spacing === void 0 ? 2 : _ref8$spacing,
|
|
524
566
|
_ref8$textAnchor = _ref8.textAnchor,
|
|
525
|
-
textAnchor = _ref8$textAnchor === void 0 ? 'center' : _ref8$textAnchor
|
|
567
|
+
textAnchor = _ref8$textAnchor === void 0 ? 'center' : _ref8$textAnchor,
|
|
568
|
+
textOffset = _ref8.textOffset;
|
|
526
569
|
|
|
527
570
|
var data = this.layer.getEncodedData();
|
|
528
571
|
this.glyphInfo = data.map(function (feature) {
|
|
@@ -530,11 +573,9 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
530
573
|
shape = _feature$shape === void 0 ? '' : _feature$shape,
|
|
531
574
|
id = feature.id,
|
|
532
575
|
_feature$size2 = feature.size,
|
|
533
|
-
size = _feature$size2 === void 0 ? 1 : _feature$size2
|
|
534
|
-
_feature$textOffset = feature.textOffset,
|
|
535
|
-
textOffset = _feature$textOffset === void 0 ? [0, 0] : _feature$textOffset;
|
|
576
|
+
size = _feature$size2 === void 0 ? 1 : _feature$size2;
|
|
536
577
|
var shaping = (0, _symbolLayout.shapeText)(shape.toString(), mapping, // @ts-ignore
|
|
537
|
-
size, textAnchor, 'left', spacing, textOffset, iconfont);
|
|
578
|
+
size, textAnchor, 'left', spacing, textOffset || feature.textOffset || [0, 0], iconfont);
|
|
538
579
|
var glyphQuads = (0, _symbolLayout.getGlyphQuads)(shaping, textOffset, false);
|
|
539
580
|
feature.shaping = shaping;
|
|
540
581
|
feature.glyphQuads = glyphQuads; // feature.centroid = calculteCentroid(coordinates);
|
|
@@ -657,16 +698,16 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
657
698
|
}, {
|
|
658
699
|
key: "reBuildModel",
|
|
659
700
|
value: function () {
|
|
660
|
-
var _reBuildModel = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
701
|
+
var _reBuildModel = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
661
702
|
var _ref10, _ref10$mask, mask, _ref10$maskInside, maskInside, model;
|
|
662
703
|
|
|
663
|
-
return _regenerator.default.wrap(function
|
|
704
|
+
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
664
705
|
while (1) {
|
|
665
|
-
switch (
|
|
706
|
+
switch (_context5.prev = _context5.next) {
|
|
666
707
|
case 0:
|
|
667
708
|
_ref10 = this.layer.getLayerConfig(), _ref10$mask = _ref10.mask, mask = _ref10$mask === void 0 ? false : _ref10$mask, _ref10$maskInside = _ref10.maskInside, maskInside = _ref10$maskInside === void 0 ? true : _ref10$maskInside;
|
|
668
709
|
this.filterGlyphs();
|
|
669
|
-
|
|
710
|
+
_context5.next = 4;
|
|
670
711
|
return this.layer.buildLayerModel({
|
|
671
712
|
moduleName: 'pointText',
|
|
672
713
|
vertexShader: textVert,
|
|
@@ -680,16 +721,16 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
680
721
|
});
|
|
681
722
|
|
|
682
723
|
case 4:
|
|
683
|
-
model =
|
|
724
|
+
model = _context5.sent;
|
|
684
725
|
// TODO 渲染流程待修改
|
|
685
|
-
this.layer.models = [model];
|
|
726
|
+
this.layer.models = [model];
|
|
686
727
|
|
|
687
728
|
case 6:
|
|
688
729
|
case "end":
|
|
689
|
-
return
|
|
730
|
+
return _context5.stop();
|
|
690
731
|
}
|
|
691
732
|
}
|
|
692
|
-
},
|
|
733
|
+
}, _callee5, this);
|
|
693
734
|
}));
|
|
694
735
|
|
|
695
736
|
function reBuildModel() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-layers",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.6",
|
|
4
4
|
"description": "L7's collection of built-in layers",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"license": "ISC",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@antv/async-hook": "^2.2.9",
|
|
30
|
-
"@antv/l7-core": "2.11.
|
|
31
|
-
"@antv/l7-maps": "2.11.
|
|
32
|
-
"@antv/l7-source": "2.11.
|
|
33
|
-
"@antv/l7-utils": "2.11.
|
|
30
|
+
"@antv/l7-core": "2.11.6",
|
|
31
|
+
"@antv/l7-maps": "2.11.6",
|
|
32
|
+
"@antv/l7-source": "2.11.6",
|
|
33
|
+
"@antv/l7-utils": "2.11.6",
|
|
34
34
|
"@babel/runtime": "^7.7.7",
|
|
35
35
|
"@mapbox/martini": "^0.2.0",
|
|
36
36
|
"@turf/clone": "^6.5.0",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@types/gl-matrix": "^2.4.5",
|
|
62
62
|
"@types/lodash": "^4.14.138"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "40a3dbc1cf1070f70054a1fc05de18c7b2c55cdc",
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|
|
67
67
|
}
|