ol 10.6.2-dev.1751533442748 → 10.6.2-dev.1751637866951
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 +1 -1
- package/dist/ol.js.map +1 -1
- package/interaction/Select.d.ts +51 -0
- package/interaction/Select.d.ts.map +1 -1
- package/interaction/Select.js +163 -55
- package/package.json +1 -1
- package/style/Icon.d.ts +6 -0
- package/style/Icon.d.ts.map +1 -1
- package/style/Icon.js +15 -0
- package/util.js +1 -1
package/interaction/Select.d.ts
CHANGED
|
@@ -334,6 +334,12 @@ declare class Select extends Interaction {
|
|
|
334
334
|
* @private
|
|
335
335
|
*/
|
|
336
336
|
private removeFeature_;
|
|
337
|
+
/**
|
|
338
|
+
* @param {Feature} feature Feature of which to get the layer
|
|
339
|
+
* @return {VectorLayer} layer, if one was found.
|
|
340
|
+
* @private
|
|
341
|
+
*/
|
|
342
|
+
private findLayerOfFeature_;
|
|
337
343
|
/**
|
|
338
344
|
* @return {import("../style/Style.js").StyleLike|null} Select style.
|
|
339
345
|
*/
|
|
@@ -353,6 +359,51 @@ declare class Select extends Interaction {
|
|
|
353
359
|
* @private
|
|
354
360
|
*/
|
|
355
361
|
private removeFeatureLayerAssociation_;
|
|
362
|
+
/**
|
|
363
|
+
* @param {import("../Feature.js").FeatureLike} feature The feature to select
|
|
364
|
+
* @param {import("../layer/Layer.js").default} layer Optional layer containing this feature
|
|
365
|
+
* @param {Array<Feature>} [selected] optional array to which selected features will be added
|
|
366
|
+
* @return {Feature|undefined} The feature, if it got selected.
|
|
367
|
+
* @private
|
|
368
|
+
*/
|
|
369
|
+
private selectFeatureInternal_;
|
|
370
|
+
/**
|
|
371
|
+
* Try to select a feature as if it was clicked and `addCondition` evaluated to True.
|
|
372
|
+
* Unlike modifying `select.getFeatures()` directly, this respects the `filter` and `layers` options (except `multi`, which is ignored).
|
|
373
|
+
* The {@link module:ol/interaction/Select~SelectEvent} fired by this won't have a mapBrowserEvent property
|
|
374
|
+
* @param {Feature} feature The feature to select
|
|
375
|
+
* @return {boolean} True if the feature was selected
|
|
376
|
+
*/
|
|
377
|
+
selectFeature(feature: Feature): boolean;
|
|
378
|
+
/**
|
|
379
|
+
* Deselects a feature if it was previously selected. Also removes layer association.
|
|
380
|
+
* @param {import("../Feature.js").FeatureLike} feature The feature to deselect
|
|
381
|
+
* @param {Array<Feature>} [deselected] optional array to which deselected features will be added
|
|
382
|
+
* @return {Feature|undefined} The feature, if it was previously selected.
|
|
383
|
+
* @private
|
|
384
|
+
*/
|
|
385
|
+
private removeFeatureInternal_;
|
|
386
|
+
/**
|
|
387
|
+
* Try to deselect a feature as if it was clicked.
|
|
388
|
+
* Compared to `select.getFeatures().remove(feature)` this causes a SelectEvent.
|
|
389
|
+
* The {@link module:ol/interaction/Select~SelectEvent} fired by this won't have a mapBrowserEvent property
|
|
390
|
+
* @param {Feature} feature The feature to deselect
|
|
391
|
+
* @return {boolean} True if the feature was deselected
|
|
392
|
+
*/
|
|
393
|
+
deselectFeature(feature: Feature): boolean;
|
|
394
|
+
/**
|
|
395
|
+
* Try to toggle a feature as if it was clicked and `toggleCondition` was True.
|
|
396
|
+
* Unlike modifying `select.getFeatures()` directly, this respects the `filter` and `layers` options (except `multi`, which is ignored).
|
|
397
|
+
* The {@link module:ol/interaction/Select~SelectEvent} fired by this won't have a mapBrowserEvent property
|
|
398
|
+
* @param {Feature} feature The feature to deselect
|
|
399
|
+
*/
|
|
400
|
+
toggleFeature(feature: Feature): void;
|
|
401
|
+
/**
|
|
402
|
+
* Deselect all features as if a user deselected them.
|
|
403
|
+
* Compared to `select.getFeatures().clear()` this causes a SelectEvent.
|
|
404
|
+
* The {@link module:ol/interaction/Select~SelectEvent} fired by this won't have a mapBrowserEvent property
|
|
405
|
+
*/
|
|
406
|
+
clearSelection(): void;
|
|
356
407
|
}
|
|
357
408
|
import Feature from '../Feature.js';
|
|
358
409
|
import Collection from '../Collection.js';
|
|
@@ -1 +1 @@
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EC;IAED;;;;;;OAMG;IACH,+BAcC;IAED;;;;;;OAMG;IACH,uBAHW,OAAO,GACN,OAAO,CAclB;IAED;;;;;;OAMG;IACH,+BAYC;IAED;;;;;;OAMG;IACH,yBAHW,OAAO,GACN,OAAO,CAUlB;IAED;;;;;OAKG;IACH,uBAFW,OAAO,QAMjB;IACD;;;;OAIG;IACH,uBAUC;CAwGF;oBApqBmB,eAAe;uBAFZ,kBAAkB;wBAWjB,kBAAkB"}
|
package/interaction/Select.js
CHANGED
|
@@ -377,19 +377,7 @@ class Select extends Interaction {
|
|
|
377
377
|
this.applySelectedStyle_(feature);
|
|
378
378
|
}
|
|
379
379
|
if (!this.getLayer(feature)) {
|
|
380
|
-
const layer =
|
|
381
|
-
this.getMap()
|
|
382
|
-
.getAllLayers()
|
|
383
|
-
.find(function (layer) {
|
|
384
|
-
if (
|
|
385
|
-
layer instanceof VectorLayer &&
|
|
386
|
-
layer.getSource() &&
|
|
387
|
-
layer.getSource().hasFeature(feature)
|
|
388
|
-
) {
|
|
389
|
-
return layer;
|
|
390
|
-
}
|
|
391
|
-
})
|
|
392
|
-
);
|
|
380
|
+
const layer = this.findLayerOfFeature_(feature);
|
|
393
381
|
if (layer) {
|
|
394
382
|
this.addFeatureLayerAssociation_(feature, layer);
|
|
395
383
|
}
|
|
@@ -406,6 +394,28 @@ class Select extends Interaction {
|
|
|
406
394
|
}
|
|
407
395
|
}
|
|
408
396
|
|
|
397
|
+
/**
|
|
398
|
+
* @param {Feature} feature Feature of which to get the layer
|
|
399
|
+
* @return {VectorLayer} layer, if one was found.
|
|
400
|
+
* @private
|
|
401
|
+
*/
|
|
402
|
+
findLayerOfFeature_(feature) {
|
|
403
|
+
const layer = /** @type {VectorLayer} */ (
|
|
404
|
+
this.getMap()
|
|
405
|
+
.getAllLayers()
|
|
406
|
+
.find(function (layer) {
|
|
407
|
+
if (
|
|
408
|
+
layer instanceof VectorLayer &&
|
|
409
|
+
layer.getSource() &&
|
|
410
|
+
layer.getSource().hasFeature(feature)
|
|
411
|
+
) {
|
|
412
|
+
return layer;
|
|
413
|
+
}
|
|
414
|
+
})
|
|
415
|
+
);
|
|
416
|
+
return layer;
|
|
417
|
+
}
|
|
418
|
+
|
|
409
419
|
/**
|
|
410
420
|
* @return {import("../style/Style.js").StyleLike|null} Select style.
|
|
411
421
|
*/
|
|
@@ -457,6 +467,116 @@ class Select extends Interaction {
|
|
|
457
467
|
delete this.featureLayerAssociation_[getUid(feature)];
|
|
458
468
|
}
|
|
459
469
|
|
|
470
|
+
/**
|
|
471
|
+
* @param {import("../Feature.js").FeatureLike} feature The feature to select
|
|
472
|
+
* @param {import("../layer/Layer.js").default} layer Optional layer containing this feature
|
|
473
|
+
* @param {Array<Feature>} [selected] optional array to which selected features will be added
|
|
474
|
+
* @return {Feature|undefined} The feature, if it got selected.
|
|
475
|
+
* @private
|
|
476
|
+
*/
|
|
477
|
+
selectFeatureInternal_(feature, layer, selected) {
|
|
478
|
+
if (!(feature instanceof Feature)) {
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
if (!this.filter_(feature, layer)) {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
const features = this.getFeatures();
|
|
485
|
+
if (!features.getArray().includes(feature)) {
|
|
486
|
+
this.addFeatureLayerAssociation_(feature, layer);
|
|
487
|
+
features.push(feature);
|
|
488
|
+
selected?.push(feature);
|
|
489
|
+
}
|
|
490
|
+
return feature;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Try to select a feature as if it was clicked and `addCondition` evaluated to True.
|
|
495
|
+
* Unlike modifying `select.getFeatures()` directly, this respects the `filter` and `layers` options (except `multi`, which is ignored).
|
|
496
|
+
* The {@link module:ol/interaction/Select~SelectEvent} fired by this won't have a mapBrowserEvent property
|
|
497
|
+
* @param {Feature} feature The feature to select
|
|
498
|
+
* @return {boolean} True if the feature was selected
|
|
499
|
+
*/
|
|
500
|
+
selectFeature(feature) {
|
|
501
|
+
const layer = this.findLayerOfFeature_(feature);
|
|
502
|
+
if (!this.layerFilter_(layer)) {
|
|
503
|
+
return false;
|
|
504
|
+
}
|
|
505
|
+
const selected = this.selectFeatureInternal_(feature, layer);
|
|
506
|
+
if (selected) {
|
|
507
|
+
this.dispatchEvent(
|
|
508
|
+
new SelectEvent(SelectEventType.SELECT, [selected], [], undefined),
|
|
509
|
+
);
|
|
510
|
+
}
|
|
511
|
+
return !!selected;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Deselects a feature if it was previously selected. Also removes layer association.
|
|
516
|
+
* @param {import("../Feature.js").FeatureLike} feature The feature to deselect
|
|
517
|
+
* @param {Array<Feature>} [deselected] optional array to which deselected features will be added
|
|
518
|
+
* @return {Feature|undefined} The feature, if it was previously selected.
|
|
519
|
+
* @private
|
|
520
|
+
*/
|
|
521
|
+
removeFeatureInternal_(feature, deselected) {
|
|
522
|
+
const features = this.getFeatures();
|
|
523
|
+
if (
|
|
524
|
+
!(feature instanceof Feature) ||
|
|
525
|
+
!features.getArray().includes(feature)
|
|
526
|
+
) {
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
features.remove(feature);
|
|
530
|
+
this.removeFeatureLayerAssociation_(feature);
|
|
531
|
+
deselected?.push(feature);
|
|
532
|
+
return feature;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Try to deselect a feature as if it was clicked.
|
|
537
|
+
* Compared to `select.getFeatures().remove(feature)` this causes a SelectEvent.
|
|
538
|
+
* The {@link module:ol/interaction/Select~SelectEvent} fired by this won't have a mapBrowserEvent property
|
|
539
|
+
* @param {Feature} feature The feature to deselect
|
|
540
|
+
* @return {boolean} True if the feature was deselected
|
|
541
|
+
*/
|
|
542
|
+
deselectFeature(feature) {
|
|
543
|
+
const deselected = this.removeFeatureInternal_(feature);
|
|
544
|
+
if (deselected) {
|
|
545
|
+
this.dispatchEvent(
|
|
546
|
+
new SelectEvent(SelectEventType.SELECT, [], [deselected], undefined),
|
|
547
|
+
);
|
|
548
|
+
}
|
|
549
|
+
return !!deselected;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Try to toggle a feature as if it was clicked and `toggleCondition` was True.
|
|
554
|
+
* Unlike modifying `select.getFeatures()` directly, this respects the `filter` and `layers` options (except `multi`, which is ignored).
|
|
555
|
+
* The {@link module:ol/interaction/Select~SelectEvent} fired by this won't have a mapBrowserEvent property
|
|
556
|
+
* @param {Feature} feature The feature to deselect
|
|
557
|
+
*/
|
|
558
|
+
toggleFeature(feature) {
|
|
559
|
+
if (!this.deselectFeature(feature)) {
|
|
560
|
+
this.selectFeature(feature);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Deselect all features as if a user deselected them.
|
|
565
|
+
* Compared to `select.getFeatures().clear()` this causes a SelectEvent.
|
|
566
|
+
* The {@link module:ol/interaction/Select~SelectEvent} fired by this won't have a mapBrowserEvent property
|
|
567
|
+
*/
|
|
568
|
+
clearSelection() {
|
|
569
|
+
clear(this.featureLayerAssociation_);
|
|
570
|
+
const features = this.getFeatures();
|
|
571
|
+
const deselected = features.getArray().slice(); // shallow copy
|
|
572
|
+
features.clear();
|
|
573
|
+
if (deselected.length !== 0) {
|
|
574
|
+
this.dispatchEvent(
|
|
575
|
+
new SelectEvent(SelectEventType.SELECT, [], deselected, undefined),
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
|
|
460
580
|
/**
|
|
461
581
|
* Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} and may change the
|
|
462
582
|
* selected state of features.
|
|
@@ -485,79 +605,67 @@ class Select extends Interaction {
|
|
|
485
605
|
*/
|
|
486
606
|
const selected = [];
|
|
487
607
|
|
|
608
|
+
// TODO: technically the way i've restructured this logic means that
|
|
609
|
+
// instead of first emptying the features list of all extra features and then adding the selected ones back,
|
|
610
|
+
// the selected features get added and then the old ones get removed.
|
|
611
|
+
// a grow then shrink, instead of a shrink then grow. I can't imagine anyone relying on this, but alas, its worth a mention.
|
|
488
612
|
if (set) {
|
|
489
613
|
// Replace the currently selected feature(s) with the feature(s) at the
|
|
490
614
|
// pixel, or clear the selected feature(s) if there is no feature at
|
|
491
615
|
// the pixel.
|
|
492
|
-
|
|
616
|
+
let foundAtCursor = false;
|
|
493
617
|
map.forEachFeatureAtPixel(
|
|
494
618
|
mapBrowserEvent.pixel,
|
|
495
|
-
/**
|
|
496
|
-
* @param {import("../Feature.js").FeatureLike} feature Feature.
|
|
497
|
-
* @param {import("../layer/Layer.js").default} layer Layer.
|
|
498
|
-
* @return {boolean|undefined} Continue to iterate over the features.
|
|
499
|
-
*/
|
|
500
619
|
(feature, layer) => {
|
|
501
|
-
|
|
502
|
-
|
|
620
|
+
foundAtCursor = true;
|
|
621
|
+
if (!this.selectFeatureInternal_(feature, layer, selected)) {
|
|
622
|
+
return; // keep going, this one wasn't selected
|
|
503
623
|
}
|
|
504
|
-
this.
|
|
505
|
-
selected.push(feature);
|
|
506
|
-
return !this.multi_;
|
|
624
|
+
return !this.multi_; // stop if not multi
|
|
507
625
|
},
|
|
508
626
|
{
|
|
509
627
|
layerFilter: this.layerFilter_,
|
|
510
628
|
hitTolerance: this.hitTolerance_,
|
|
511
629
|
},
|
|
512
630
|
);
|
|
631
|
+
|
|
513
632
|
for (let i = features.getLength() - 1; i >= 0; --i) {
|
|
514
633
|
const feature = features.item(i);
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
634
|
+
if (
|
|
635
|
+
// remove all but selected, if there were any selected
|
|
636
|
+
(selected.length > 0 && !selected.includes(feature)) ||
|
|
637
|
+
// remove all, if click outside of layer
|
|
638
|
+
!foundAtCursor
|
|
639
|
+
) {
|
|
640
|
+
this.removeFeatureInternal_(feature, deselected);
|
|
522
641
|
}
|
|
523
642
|
}
|
|
524
|
-
if (selected.length !== 0) {
|
|
525
|
-
features.extend(selected);
|
|
526
|
-
}
|
|
527
643
|
} else {
|
|
528
644
|
// Modify the currently selected feature(s).
|
|
529
645
|
map.forEachFeatureAtPixel(
|
|
530
646
|
mapBrowserEvent.pixel,
|
|
531
|
-
/**
|
|
532
|
-
* @param {import("../Feature.js").FeatureLike} feature Feature.
|
|
533
|
-
* @param {import("../layer/Layer.js").default} layer Layer.
|
|
534
|
-
* @return {boolean|undefined} Continue to iterate over the features.
|
|
535
|
-
*/
|
|
536
647
|
(feature, layer) => {
|
|
537
|
-
|
|
538
|
-
|
|
648
|
+
let modifiedFeature;
|
|
649
|
+
if (remove || toggle) {
|
|
650
|
+
modifiedFeature = this.removeFeatureInternal_(feature, deselected);
|
|
539
651
|
}
|
|
540
|
-
if ((add || toggle) && !
|
|
541
|
-
this.
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
this
|
|
652
|
+
if ((add || toggle) && !modifiedFeature) {
|
|
653
|
+
modifiedFeature = this.selectFeatureInternal_(
|
|
654
|
+
feature,
|
|
655
|
+
layer,
|
|
656
|
+
selected,
|
|
657
|
+
);
|
|
658
|
+
}
|
|
659
|
+
if (!modifiedFeature) {
|
|
660
|
+
return; // keep going, this one wasn't removed/selected
|
|
549
661
|
}
|
|
550
|
-
return !this.multi_;
|
|
662
|
+
return !this.multi_; // stop if not multi
|
|
551
663
|
},
|
|
552
664
|
{
|
|
553
665
|
layerFilter: this.layerFilter_,
|
|
554
666
|
hitTolerance: this.hitTolerance_,
|
|
555
667
|
},
|
|
556
668
|
);
|
|
557
|
-
for (let j = deselected.length - 1; j >= 0; --j) {
|
|
558
|
-
features.remove(deselected[j]);
|
|
559
|
-
}
|
|
560
|
-
features.extend(selected);
|
|
561
669
|
}
|
|
562
670
|
if (selected.length > 0 || deselected.length > 0) {
|
|
563
671
|
this.dispatchEvent(
|
package/package.json
CHANGED
package/style/Icon.d.ts
CHANGED
|
@@ -209,6 +209,12 @@ declare class Icon extends ImageStyle {
|
|
|
209
209
|
* @api
|
|
210
210
|
*/
|
|
211
211
|
getSrc(): string | undefined;
|
|
212
|
+
/**
|
|
213
|
+
* Set the image URI
|
|
214
|
+
* @param {string} src Image source URI
|
|
215
|
+
* @api
|
|
216
|
+
*/
|
|
217
|
+
setSrc(src: string): void;
|
|
212
218
|
/**
|
|
213
219
|
* Get the width of the icon (in pixels). Will return undefined when the icon image is not yet loaded.
|
|
214
220
|
* @return {number} Icon width (in pixels).
|
package/style/Icon.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.d.ts","sourceRoot":"","sources":["Icon.js"],"names":[],"mappings":";;;;8BAYa,UAAU,GAAG,QAAQ;;;;yBAKrB,aAAa,GAAG,cAAc,GAAG,UAAU,GAAG,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DtE;;;;GAIG;AACH;IACE;;OAEG;IACH,sBAFW,OAAO,EA0MjB;IAtKC;;;OAGG;IACH,gBAAyE;IAEzE;;;OAGG;IACH,0BAA6B;IAE7B;;;OAGG;IACH,sBACwE;IAExE;;;OAGG;IACH,sBACwE;IAExE;;;OAGG;IACH,sBACwE;IAExE;;;OAGG;IACH,qBACgE;IA0ChE;;;OAGG;IACH,eAAyE;IAEzE;;;OAGG;IACH,mBAMC;IAED;;;OAGG;IACH,gBAAqE;IACrE;;;OAGG;IACH,sBACwE;IAExE;;;OAGG;IACH,gBAAmB;IAEnB;;;OAGG;IACH,cAA6D;IAoBvD,qCAA8B;IA4BtC;;;;;OAKG;IACH,kBAJY,IAAI,CAoCf;IA8DD;;;;;;OAMG;IACH,kBAHW,KAAK,CAAC,MAAM,CAAC,QAMvB;IAED;;;;OAIG;IACH,YAHY,OAAO,aAAa,EAAE,KAAK,CAKtC;IAED;;;;;;;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,GAAC,iBAAiB,GAAC,WAAW,CAKzD;IAsCD;;;;OAIG;IACH,UAHY,MAAM,GAAC,SAAS,CAK3B;IAED;;;;OAIG;IACH,YAHW,MAAM,QAWhB;IAYD;;;;OAIG;IACH,YAHY,MAAM,CAYjB;IAED;;;;OAIG;IACH,aAHY,MAAM,CAYjB;CAgDF;uBAllBsB,YAAY"}
|
package/style/Icon.js
CHANGED
|
@@ -498,6 +498,21 @@ class Icon extends ImageStyle {
|
|
|
498
498
|
return this.iconImage_.getSrc();
|
|
499
499
|
}
|
|
500
500
|
|
|
501
|
+
/**
|
|
502
|
+
* Set the image URI
|
|
503
|
+
* @param {string} src Image source URI
|
|
504
|
+
* @api
|
|
505
|
+
*/
|
|
506
|
+
setSrc(src) {
|
|
507
|
+
this.iconImage_ = getIconImage(
|
|
508
|
+
null,
|
|
509
|
+
src,
|
|
510
|
+
this.crossOrigin_,
|
|
511
|
+
ImageState.IDLE,
|
|
512
|
+
this.color_,
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
|
|
501
516
|
/**
|
|
502
517
|
* Get the size of the icon (in pixels).
|
|
503
518
|
* @return {import("../size.js").Size} Image size.
|
package/util.js
CHANGED