ol 8.1.1-dev.1694608919656 → 8.1.1-dev.1694687206621

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.
Files changed (50) hide show
  1. package/Feature.d.ts +2 -2
  2. package/Feature.d.ts.map +1 -1
  3. package/Feature.js +1 -1
  4. package/color.d.ts +1 -1
  5. package/color.d.ts.map +1 -1
  6. package/color.js +12 -11
  7. package/dist/ol.js +2 -2
  8. package/dist/ol.js.map +1 -1
  9. package/format/EsriJSON.d.ts +8 -0
  10. package/format/EsriJSON.d.ts.map +1 -1
  11. package/format/Feature.d.ts +79 -5
  12. package/format/Feature.d.ts.map +1 -1
  13. package/format/Feature.js +151 -11
  14. package/format/GeoJSON.d.ts +11 -0
  15. package/format/GeoJSON.d.ts.map +1 -1
  16. package/format/GeoJSON.js +144 -52
  17. package/format/JSONFeature.d.ts +4 -24
  18. package/format/JSONFeature.d.ts.map +1 -1
  19. package/format/JSONFeature.js +4 -4
  20. package/format/MVT.d.ts.map +1 -1
  21. package/format/MVT.js +3 -2
  22. package/format/TopoJSON.d.ts +8 -0
  23. package/format/TopoJSON.d.ts.map +1 -1
  24. package/geom/SimpleGeometry.d.ts +5 -0
  25. package/geom/SimpleGeometry.d.ts.map +1 -1
  26. package/geom/SimpleGeometry.js +1 -1
  27. package/interaction/DragAndDrop.d.ts +1 -1
  28. package/interaction/Draw.d.ts +2 -2
  29. package/interaction/Modify.d.ts +1 -1
  30. package/interaction/Snap.d.ts +1 -1
  31. package/layer/BaseVector.d.ts +2 -2
  32. package/layer/Graticule.d.ts +2 -1
  33. package/layer/Graticule.d.ts.map +1 -1
  34. package/layer/Heatmap.d.ts +2 -2
  35. package/layer/Heatmap.js +1 -1
  36. package/layer/Vector.d.ts +1 -1
  37. package/layer/VectorImage.d.ts +2 -2
  38. package/layer/WebGLPoints.d.ts +4 -4
  39. package/layer/WebGLPoints.js +2 -2
  40. package/package.json +2 -1
  41. package/render/Feature.d.ts +33 -11
  42. package/render/Feature.d.ts.map +1 -1
  43. package/render/Feature.js +115 -21
  44. package/render/webgl/MixedGeometryBatch.d.ts.map +1 -1
  45. package/render/webgl/MixedGeometryBatch.js +1 -3
  46. package/source/Cluster.d.ts +2 -2
  47. package/source/Vector.d.ts +74 -66
  48. package/source/Vector.d.ts.map +1 -1
  49. package/source/Vector.js +98 -67
  50. package/util.js +1 -1
package/source/Vector.js CHANGED
@@ -8,6 +8,7 @@ import Event from '../events/Event.js';
8
8
  import EventType from '../events/EventType.js';
9
9
  import ObjectEventType from '../ObjectEventType.js';
10
10
  import RBush from '../structs/RBush.js';
11
+ import RenderFeature from '../render/Feature.js';
11
12
  import Source from './Source.js';
12
13
  import VectorEventType from './VectorEventType.js';
13
14
  import {TRUE, VOID} from '../functions.js';
@@ -33,27 +34,27 @@ import {xhr} from '../featureloader.js';
33
34
  * @classdesc
34
35
  * Events emitted by {@link module:ol/source/Vector~VectorSource} instances are instances of this
35
36
  * type.
36
- * @template {import("../geom/Geometry.js").default} [Geometry=import("../geom/Geometry.js").default]
37
+ * @template {import("../Feature.js").FeatureLike} [FeatureClass=import("../Feature.js").default]
37
38
  */
38
39
  export class VectorSourceEvent extends Event {
39
40
  /**
40
41
  * @param {string} type Type.
41
- * @param {import("../Feature.js").default<Geometry>} [feature] Feature.
42
- * @param {Array<import("../Feature.js").default<Geometry>>} [features] Features.
42
+ * @param {FeatureClass} [feature] Feature.
43
+ * @param {Array<FeatureClass>} [features] Features.
43
44
  */
44
45
  constructor(type, feature, features) {
45
46
  super(type);
46
47
 
47
48
  /**
48
49
  * The added or removed feature for the `ADDFEATURE` and `REMOVEFEATURE` events, `undefined` otherwise.
49
- * @type {import("../Feature.js").default<Geometry>|undefined}
50
+ * @type {FeatureClass|undefined}
50
51
  * @api
51
52
  */
52
53
  this.feature = feature;
53
54
 
54
55
  /**
55
56
  * The loaded features for the `FEATURESLOADED` event, `undefined` otherwise.
56
- * @type {Array<import("../Feature.js").default<Geometry>>|undefined}
57
+ * @type {Array<FeatureClass>|undefined}
57
58
  * @api
58
59
  */
59
60
  this.features = features;
@@ -70,10 +71,10 @@ export class VectorSourceEvent extends Event {
70
71
  */
71
72
 
72
73
  /**
73
- * @template {import("../geom/Geometry.js").default} [Geometry=import("../geom/Geometry.js").default]
74
+ * @template {import("../Feature.js").FeatureLike} [FeatureClass=import("../Feature.js").default]
74
75
  * @typedef {Object} Options
75
76
  * @property {import("./Source.js").AttributionLike} [attributions] Attributions.
76
- * @property {Array<import("../Feature.js").default<Geometry>>|Collection<import("../Feature.js").default<Geometry>>} [features]
77
+ * @property {Array<FeatureClass>|Collection<FeatureClass>} [features]
77
78
  * Features. If provided as {@link module:ol/Collection~Collection}, the features in the source
78
79
  * and the collection will stay in sync.
79
80
  * @property {import("../format/Feature.js").default} [format] The feature format used by the XHR
@@ -170,11 +171,11 @@ export class VectorSourceEvent extends Event {
170
171
  *
171
172
  * @fires VectorSourceEvent
172
173
  * @api
173
- * @template {import("../geom/Geometry.js").default} [Geometry=import("../geom/Geometry.js").default]
174
+ * @template {import("../Feature.js").FeatureLike} [FeatureClass=import("../Feature.js").default]
174
175
  */
175
176
  class VectorSource extends Source {
176
177
  /**
177
- * @param {Options<Geometry>} [options] Vector source options.
178
+ * @param {Options<FeatureClass>} [options] Vector source options.
178
179
  */
179
180
  constructor(options) {
180
181
  options = options || {};
@@ -249,7 +250,7 @@ class VectorSource extends Source {
249
250
 
250
251
  /**
251
252
  * @private
252
- * @type {RBush<import("../Feature.js").default<Geometry>>}
253
+ * @type {RBush<FeatureClass>}
253
254
  */
254
255
  this.featuresRtree_ = useSpatialIndex ? new RBush() : null;
255
256
 
@@ -267,21 +268,21 @@ class VectorSource extends Source {
267
268
 
268
269
  /**
269
270
  * @private
270
- * @type {!Object<string, import("../Feature.js").default<Geometry>>}
271
+ * @type {!Object<string, FeatureClass>}
271
272
  */
272
273
  this.nullGeometryFeatures_ = {};
273
274
 
274
275
  /**
275
276
  * A lookup of features by id (the return from feature.getId()).
276
277
  * @private
277
- * @type {!Object<string, import("../Feature.js").default<Geometry>>}
278
+ * @type {!Object<string, FeatureClass|Array<RenderFeature>>}
278
279
  */
279
280
  this.idIndex_ = {};
280
281
 
281
282
  /**
282
283
  * A lookup of features by uid (using getUid(feature)).
283
284
  * @private
284
- * @type {!Object<string, import("../Feature.js").default<Geometry>>}
285
+ * @type {!Object<string, FeatureClass>}
285
286
  */
286
287
  this.uidIndex_ = {};
287
288
 
@@ -293,13 +294,13 @@ class VectorSource extends Source {
293
294
 
294
295
  /**
295
296
  * @private
296
- * @type {Collection<import("../Feature.js").default<Geometry>>|null}
297
+ * @type {Collection<FeatureClass>|null}
297
298
  */
298
299
  this.featuresCollection_ = null;
299
300
 
300
- /** @type {Collection<import("../Feature.js").default<Geometry>>} */
301
+ /** @type {Collection<FeatureClass>} */
301
302
  let collection;
302
- /** @type {Array<import("../Feature.js").default<Geometry>>} */
303
+ /** @type {Array<FeatureClass>} */
303
304
  let features;
304
305
  if (Array.isArray(options.features)) {
305
306
  features = options.features;
@@ -327,7 +328,7 @@ class VectorSource extends Source {
327
328
  * Note: this also applies if an {@link module:ol/Collection~Collection} is used for features,
328
329
  * meaning that if a feature with a duplicate id is added in the collection, it will
329
330
  * be removed from it right away.
330
- * @param {import("../Feature.js").default<Geometry>} feature Feature to add.
331
+ * @param {FeatureClass} feature Feature to add.
331
332
  * @api
332
333
  */
333
334
  addFeature(feature) {
@@ -337,7 +338,7 @@ class VectorSource extends Source {
337
338
 
338
339
  /**
339
340
  * Add a feature without firing a `change` event.
340
- * @param {import("../Feature.js").default<Geometry>} feature Feature.
341
+ * @param {FeatureClass} feature Feature.
341
342
  * @protected
342
343
  */
343
344
  addFeatureInternal(feature) {
@@ -369,10 +370,13 @@ class VectorSource extends Source {
369
370
 
370
371
  /**
371
372
  * @param {string} featureKey Unique identifier for the feature.
372
- * @param {import("../Feature.js").default<Geometry>} feature The feature.
373
+ * @param {FeatureClass} feature The feature.
373
374
  * @private
374
375
  */
375
376
  setupChangeEvents_(featureKey, feature) {
377
+ if (feature instanceof RenderFeature) {
378
+ return;
379
+ }
376
380
  this.featureChangeKeys_[featureKey] = [
377
381
  listen(feature, EventType.CHANGE, this.handleFeatureChange_, this),
378
382
  listen(
@@ -386,17 +390,28 @@ class VectorSource extends Source {
386
390
 
387
391
  /**
388
392
  * @param {string} featureKey Unique identifier for the feature.
389
- * @param {import("../Feature.js").default<Geometry>} feature The feature.
393
+ * @param {FeatureClass} feature The feature.
390
394
  * @return {boolean} The feature is "valid", in the sense that it is also a
391
395
  * candidate for insertion into the Rtree.
392
396
  * @private
393
397
  */
394
398
  addToIndex_(featureKey, feature) {
395
399
  let valid = true;
396
- const id = feature.getId();
397
- if (id !== undefined) {
398
- if (!(id.toString() in this.idIndex_)) {
399
- this.idIndex_[id.toString()] = feature;
400
+ if (feature.getId() !== undefined) {
401
+ const id = String(feature.getId());
402
+ if (!(id in this.idIndex_)) {
403
+ this.idIndex_[id] = feature;
404
+ } else if (feature instanceof RenderFeature) {
405
+ const indexedFeature = this.idIndex_[id];
406
+ if (!(indexedFeature instanceof RenderFeature)) {
407
+ valid = false;
408
+ } else {
409
+ if (!Array.isArray(indexedFeature)) {
410
+ this.idIndex_[id] = [indexedFeature, feature];
411
+ } else {
412
+ indexedFeature.push(feature);
413
+ }
414
+ }
400
415
  } else {
401
416
  valid = false;
402
417
  }
@@ -413,7 +428,7 @@ class VectorSource extends Source {
413
428
 
414
429
  /**
415
430
  * Add a batch of features to the source.
416
- * @param {Array<import("../Feature.js").default<Geometry>>} features Features to add.
431
+ * @param {Array<FeatureClass>} features Features to add.
417
432
  * @api
418
433
  */
419
434
  addFeatures(features) {
@@ -423,12 +438,14 @@ class VectorSource extends Source {
423
438
 
424
439
  /**
425
440
  * Add features without firing a `change` event.
426
- * @param {Array<import("../Feature.js").default<Geometry>>} features Features.
441
+ * @param {Array<FeatureClass>} features Features.
427
442
  * @protected
428
443
  */
429
444
  addFeaturesInternal(features) {
430
445
  const extents = [];
446
+ /** @type {Array<FeatureClass>} */
431
447
  const newFeatures = [];
448
+ /** @type Array<FeatureClass> */
432
449
  const geometryFeatures = [];
433
450
 
434
451
  for (let i = 0, length = features.length; i < length; i++) {
@@ -467,7 +484,7 @@ class VectorSource extends Source {
467
484
  }
468
485
 
469
486
  /**
470
- * @param {!Collection<import("../Feature.js").default<Geometry>>} collection Collection.
487
+ * @param {!Collection<FeatureClass>} collection Collection.
471
488
  * @private
472
489
  */
473
490
  bindFeaturesCollection_(collection) {
@@ -475,7 +492,7 @@ class VectorSource extends Source {
475
492
  this.addEventListener(
476
493
  VectorEventType.ADDFEATURE,
477
494
  /**
478
- * @param {VectorSourceEvent<Geometry>} evt The vector source event
495
+ * @param {VectorSourceEvent<FeatureClass>} evt The vector source event
479
496
  */
480
497
  function (evt) {
481
498
  if (!modifyingCollection) {
@@ -488,7 +505,7 @@ class VectorSource extends Source {
488
505
  this.addEventListener(
489
506
  VectorEventType.REMOVEFEATURE,
490
507
  /**
491
- * @param {VectorSourceEvent<Geometry>} evt The vector source event
508
+ * @param {VectorSourceEvent<FeatureClass>} evt The vector source event
492
509
  */
493
510
  function (evt) {
494
511
  if (!modifyingCollection) {
@@ -501,7 +518,7 @@ class VectorSource extends Source {
501
518
  collection.addEventListener(
502
519
  CollectionEventType.ADD,
503
520
  /**
504
- * @param {import("../Collection.js").CollectionEvent<import("../Feature.js").default<Geometry>>} evt The collection event
521
+ * @param {import("../Collection.js").CollectionEvent<FeatureClass>} evt The collection event
505
522
  */
506
523
  (evt) => {
507
524
  if (!modifyingCollection) {
@@ -514,7 +531,7 @@ class VectorSource extends Source {
514
531
  collection.addEventListener(
515
532
  CollectionEventType.REMOVE,
516
533
  /**
517
- * @param {import("../Collection.js").CollectionEvent<import("../Feature.js").default<Geometry>>} evt The collection event
534
+ * @param {import("../Collection.js").CollectionEvent<FeatureClass>} evt The collection event
518
535
  */
519
536
  (evt) => {
520
537
  if (!modifyingCollection) {
@@ -574,7 +591,7 @@ class VectorSource extends Source {
574
591
  * stop and the function will return the same value.
575
592
  * Note: this function only iterate through the feature that have a defined geometry.
576
593
  *
577
- * @param {function(import("../Feature.js").default<Geometry>): T} callback Called with each feature
594
+ * @param {function(FeatureClass): T} callback Called with each feature
578
595
  * on the source. Return a truthy value to stop iteration.
579
596
  * @return {T|undefined} The return value from the last call to the callback.
580
597
  * @template T
@@ -595,8 +612,11 @@ class VectorSource extends Source {
595
612
  * a "truthy" value, iteration will stop and the function will return the same
596
613
  * value.
597
614
  *
615
+ * For {@link module:ol/render/Feature~RenderFeature} features, the callback will be
616
+ * called for all features.
617
+ *
598
618
  * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
599
- * @param {function(import("../Feature.js").default<Geometry>): T} callback Called with each feature
619
+ * @param {function(FeatureClass): T} callback Called with each feature
600
620
  * whose goemetry contains the provided coordinate.
601
621
  * @return {T|undefined} The return value from the last call to the callback.
602
622
  * @template T
@@ -605,7 +625,10 @@ class VectorSource extends Source {
605
625
  const extent = [coordinate[0], coordinate[1], coordinate[0], coordinate[1]];
606
626
  return this.forEachFeatureInExtent(extent, function (feature) {
607
627
  const geometry = feature.getGeometry();
608
- if (geometry.intersectsCoordinate(coordinate)) {
628
+ if (
629
+ geometry instanceof RenderFeature ||
630
+ geometry.intersectsCoordinate(coordinate)
631
+ ) {
609
632
  return callback(feature);
610
633
  }
611
634
  return undefined;
@@ -625,7 +648,7 @@ class VectorSource extends Source {
625
648
  * features, equivalent to {@link module:ol/source/Vector~VectorSource#forEachFeature #forEachFeature()}.
626
649
  *
627
650
  * @param {import("../extent.js").Extent} extent Extent.
628
- * @param {function(import("../Feature.js").default<Geometry>): T} callback Called with each feature
651
+ * @param {function(FeatureClass): T} callback Called with each feature
629
652
  * whose bounding box intersects the provided extent.
630
653
  * @return {T|undefined} The return value from the last call to the callback.
631
654
  * @template T
@@ -649,7 +672,7 @@ class VectorSource extends Source {
649
672
  * {@link module:ol/source/Vector~VectorSource#forEachFeatureInExtent #forEachFeatureInExtent()} method instead.
650
673
  *
651
674
  * @param {import("../extent.js").Extent} extent Extent.
652
- * @param {function(import("../Feature.js").default<Geometry>): T} callback Called with each feature
675
+ * @param {function(FeatureClass): T} callback Called with each feature
653
676
  * whose geometry intersects the provided extent.
654
677
  * @return {T|undefined} The return value from the last call to the callback.
655
678
  * @template T
@@ -659,12 +682,15 @@ class VectorSource extends Source {
659
682
  return this.forEachFeatureInExtent(
660
683
  extent,
661
684
  /**
662
- * @param {import("../Feature.js").default<Geometry>} feature Feature.
685
+ * @param {FeatureClass} feature Feature.
663
686
  * @return {T|undefined} The return value from the last call to the callback.
664
687
  */
665
688
  function (feature) {
666
689
  const geometry = feature.getGeometry();
667
- if (geometry.intersectsExtent(extent)) {
690
+ if (
691
+ geometry instanceof RenderFeature ||
692
+ geometry.intersectsExtent(extent)
693
+ ) {
668
694
  const result = callback(feature);
669
695
  if (result) {
670
696
  return result;
@@ -678,7 +704,7 @@ class VectorSource extends Source {
678
704
  * Get the features collection associated with this source. Will be `null`
679
705
  * unless the source was configured with `useSpatialIndex` set to `false`, or
680
706
  * with an {@link module:ol/Collection~Collection} as `features`.
681
- * @return {Collection<import("../Feature.js").default<Geometry>>|null} The collection of features.
707
+ * @return {Collection<FeatureClass>|null} The collection of features.
682
708
  * @api
683
709
  */
684
710
  getFeaturesCollection() {
@@ -688,7 +714,7 @@ class VectorSource extends Source {
688
714
  /**
689
715
  * Get a snapshot of the features currently on the source in random order. The returned array
690
716
  * is a copy, the features are references to the features in the source.
691
- * @return {Array<import("../Feature.js").default<Geometry>>} Features.
717
+ * @return {Array<FeatureClass>} Features.
692
718
  * @api
693
719
  */
694
720
  getFeatures() {
@@ -701,15 +727,13 @@ class VectorSource extends Source {
701
727
  extend(features, Object.values(this.nullGeometryFeatures_));
702
728
  }
703
729
  }
704
- return /** @type {Array<import("../Feature.js").default<Geometry>>} */ (
705
- features
706
- );
730
+ return features;
707
731
  }
708
732
 
709
733
  /**
710
734
  * Get all features whose geometry intersects the provided coordinate.
711
735
  * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
712
- * @return {Array<import("../Feature.js").default<Geometry>>} Features.
736
+ * @return {Array<import("../Feature.js").default>} Features.
713
737
  * @api
714
738
  */
715
739
  getFeaturesAtCoordinate(coordinate) {
@@ -731,7 +755,7 @@ class VectorSource extends Source {
731
755
  * @param {import("../extent.js").Extent} extent Extent.
732
756
  * @param {import("../proj/Projection.js").default} [projection] Include features
733
757
  * where `extent` exceeds the x-axis bounds of `projection` and wraps around the world.
734
- * @return {Array<import("../Feature.js").default<Geometry>>} Features.
758
+ * @return {Array<FeatureClass>} Features.
735
759
  * @api
736
760
  */
737
761
  getFeaturesInExtent(extent, projection) {
@@ -758,12 +782,13 @@ class VectorSource extends Source {
758
782
  * Get the closest feature to the provided coordinate.
759
783
  *
760
784
  * This method is not available when the source is configured with
761
- * `useSpatialIndex` set to `false`.
785
+ * `useSpatialIndex` set to `false` and the features in this source are of type
786
+ * {@link module:ol/Feature~Feature}.
762
787
  * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
763
- * @param {function(import("../Feature.js").default<Geometry>):boolean} [filter] Feature filter function.
788
+ * @param {function(FeatureClass):boolean} [filter] Feature filter function.
764
789
  * The filter function will receive one argument, the {@link module:ol/Feature~Feature feature}
765
790
  * and it should return a boolean value. By default, no filtering is made.
766
- * @return {import("../Feature.js").default<Geometry>} Closest feature.
791
+ * @return {FeatureClass} Closest feature.
767
792
  * @api
768
793
  */
769
794
  getClosestFeatureToCoordinate(coordinate, filter) {
@@ -784,18 +809,16 @@ class VectorSource extends Source {
784
809
  this.featuresRtree_.forEachInExtent(
785
810
  extent,
786
811
  /**
787
- * @param {import("../Feature.js").default<Geometry>} feature Feature.
812
+ * @param {FeatureClass} feature Feature.
788
813
  */
789
814
  function (feature) {
790
815
  if (filter(feature)) {
791
816
  const geometry = feature.getGeometry();
792
817
  const previousMinSquaredDistance = minSquaredDistance;
793
- minSquaredDistance = geometry.closestPointXY(
794
- x,
795
- y,
796
- closestPoint,
797
- minSquaredDistance
798
- );
818
+ minSquaredDistance =
819
+ geometry instanceof RenderFeature
820
+ ? 0
821
+ : geometry.closestPointXY(x, y, closestPoint, minSquaredDistance);
799
822
  if (minSquaredDistance < previousMinSquaredDistance) {
800
823
  closestFeature = feature;
801
824
  // This is sneaky. Reduce the extent that it is currently being
@@ -829,12 +852,15 @@ class VectorSource extends Source {
829
852
  }
830
853
 
831
854
  /**
832
- * Get a feature by its identifier (the value returned by feature.getId()).
855
+ * Get a feature by its identifier (the value returned by feature.getId()). When `RenderFeature`s
856
+ * are used, `getFeatureById()` can return an array of `RenderFeature`s. This allows for handling
857
+ * of `GeometryCollection` geometries, where format readers create one `RenderFeature` per
858
+ * `GeometryCollection` member.
833
859
  * Note that the index treats string and numeric identifiers as the same. So
834
860
  * `source.getFeatureById(2)` will return a feature with id `'2'` or `2`.
835
861
  *
836
862
  * @param {string|number} id Feature identifier.
837
- * @return {import("../Feature.js").default<Geometry>|null} The feature (or `null` if not found).
863
+ * @return {FeatureClass|Array<RenderFeature>|null} The feature (or `null` if not found).
838
864
  * @api
839
865
  */
840
866
  getFeatureById(id) {
@@ -846,7 +872,7 @@ class VectorSource extends Source {
846
872
  * Get a feature by its internal unique identifier (using `getUid`).
847
873
  *
848
874
  * @param {string} uid Feature identifier.
849
- * @return {import("../Feature.js").default<Geometry>|null} The feature (or `null` if not found).
875
+ * @return {FeatureClass|null} The feature (or `null` if not found).
850
876
  */
851
877
  getFeatureByUid(uid) {
852
878
  const feature = this.uidIndex_[uid];
@@ -885,9 +911,7 @@ class VectorSource extends Source {
885
911
  * @private
886
912
  */
887
913
  handleFeatureChange_(event) {
888
- const feature = /** @type {import("../Feature.js").default<Geometry>} */ (
889
- event.target
890
- );
914
+ const feature = /** @type {FeatureClass} */ (event.target);
891
915
  const featureKey = getUid(feature);
892
916
  const geometry = feature.getGeometry();
893
917
  if (!geometry) {
@@ -929,7 +953,7 @@ class VectorSource extends Source {
929
953
 
930
954
  /**
931
955
  * Returns true if the feature is contained within the source.
932
- * @param {import("../Feature.js").default<Geometry>} feature Feature.
956
+ * @param {FeatureClass} feature Feature.
933
957
  * @return {boolean} Has feature.
934
958
  * @api
935
959
  */
@@ -1039,7 +1063,7 @@ class VectorSource extends Source {
1039
1063
  * Remove a single feature from the source. If you want to remove all features
1040
1064
  * at once, use the {@link module:ol/source/Vector~VectorSource#clear #clear()} method
1041
1065
  * instead.
1042
- * @param {import("../Feature.js").default<Geometry>} feature Feature to remove.
1066
+ * @param {FeatureClass} feature Feature to remove.
1043
1067
  * @api
1044
1068
  */
1045
1069
  removeFeature(feature) {
@@ -1062,8 +1086,8 @@ class VectorSource extends Source {
1062
1086
 
1063
1087
  /**
1064
1088
  * Remove feature without firing a `change` event.
1065
- * @param {import("../Feature.js").default<Geometry>} feature Feature.
1066
- * @return {import("../Feature.js").default<Geometry>|undefined} The removed feature
1089
+ * @param {FeatureClass} feature Feature.
1090
+ * @return {FeatureClass|undefined} The removed feature
1067
1091
  * (or undefined if the feature was not found).
1068
1092
  * @protected
1069
1093
  */
@@ -1089,14 +1113,21 @@ class VectorSource extends Source {
1089
1113
  /**
1090
1114
  * Remove a feature from the id index. Called internally when the feature id
1091
1115
  * may have changed.
1092
- * @param {import("../Feature.js").default<Geometry>} feature The feature.
1116
+ * @param {FeatureClass} feature The feature.
1093
1117
  * @return {boolean} Removed the feature from the index.
1094
1118
  * @private
1095
1119
  */
1096
1120
  removeFromIdIndex_(feature) {
1097
1121
  let removed = false;
1098
1122
  for (const id in this.idIndex_) {
1099
- if (this.idIndex_[id] === feature) {
1123
+ const indexedFeature = this.idIndex_[id];
1124
+ if (
1125
+ feature instanceof RenderFeature &&
1126
+ Array.isArray(indexedFeature) &&
1127
+ indexedFeature.includes(feature)
1128
+ ) {
1129
+ indexedFeature.splice(indexedFeature.indexOf(feature), 1);
1130
+ } else if (this.idIndex_[id] === feature) {
1100
1131
  delete this.idIndex_[id];
1101
1132
  removed = true;
1102
1133
  break;
package/util.js CHANGED
@@ -33,4 +33,4 @@ export function getUid(obj) {
33
33
  * OpenLayers version.
34
34
  * @type {string}
35
35
  */
36
- export const VERSION = '8.1.1-dev.1694608919656';
36
+ export const VERSION = '8.1.1-dev.1694687206621';