Make VectorSource Options generic
This commit is contained in:
@@ -72,7 +72,7 @@ export class VectorSourceEvent extends Event {
|
|||||||
/**
|
/**
|
||||||
* @typedef {Object} Options
|
* @typedef {Object} Options
|
||||||
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
|
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
|
||||||
* @property {Array<import("../Feature.js").default>|Collection<import("../Feature.js").default>} [features]
|
* @property {Array<import("../Feature.js").default<Geometry>>|Collection<import("../Feature.js").default<Geometry>>} [features]
|
||||||
* Features. If provided as {@link module:ol/Collection~Collection}, the features in the source
|
* Features. If provided as {@link module:ol/Collection~Collection}, the features in the source
|
||||||
* and the collection will stay in sync.
|
* and the collection will stay in sync.
|
||||||
* @property {import("../format/Feature.js").default} [format] The feature format used by the XHR
|
* @property {import("../format/Feature.js").default} [format] The feature format used by the XHR
|
||||||
@@ -159,6 +159,7 @@ export class VectorSourceEvent extends Event {
|
|||||||
* @property {boolean} [wrapX=true] Wrap the world horizontally. For vector editing across the
|
* @property {boolean} [wrapX=true] Wrap the world horizontally. For vector editing across the
|
||||||
* -180° and 180° meridians to work properly, this should be set to `false`. The
|
* -180° and 180° meridians to work properly, this should be set to `false`. The
|
||||||
* resulting geometry coordinates will then exceed the world bounds.
|
* resulting geometry coordinates will then exceed the world bounds.
|
||||||
|
* @template {import("../geom/Geometry.js").default} [Geometry=import("../geom/Geometry.js").default]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -173,7 +174,7 @@ export class VectorSourceEvent extends Event {
|
|||||||
*/
|
*/
|
||||||
class VectorSource extends Source {
|
class VectorSource extends Source {
|
||||||
/**
|
/**
|
||||||
* @param {Options} [opt_options] Vector source options.
|
* @param {Options<Geometry>} [opt_options] Vector source options.
|
||||||
*/
|
*/
|
||||||
constructor(opt_options) {
|
constructor(opt_options) {
|
||||||
const options = opt_options || {};
|
const options = opt_options || {};
|
||||||
@@ -296,17 +297,17 @@ class VectorSource extends Source {
|
|||||||
*/
|
*/
|
||||||
this.featuresCollection_ = null;
|
this.featuresCollection_ = null;
|
||||||
|
|
||||||
let collection, features;
|
/** @type {Collection<import("../Feature.js").default<Geometry>>} */
|
||||||
|
let collection;
|
||||||
|
/** @type {Array<import("../Feature.js").default<Geometry>>} */
|
||||||
|
let features;
|
||||||
if (Array.isArray(options.features)) {
|
if (Array.isArray(options.features)) {
|
||||||
features =
|
features =
|
||||||
/** @type {Array<import("../Feature.js").default<Geometry>>} */ (
|
/** @type {Array<import("../Feature.js").default<Geometry>>} */ (
|
||||||
options.features
|
options.features
|
||||||
);
|
);
|
||||||
} else if (options.features) {
|
} else if (options.features) {
|
||||||
collection =
|
collection = options.features;
|
||||||
/** @type {Collection<import("../Feature.js").default<Geometry>>} */ (
|
|
||||||
options.features
|
|
||||||
);
|
|
||||||
features = collection.getArray();
|
features = collection.getArray();
|
||||||
}
|
}
|
||||||
if (!useSpatialIndex && collection === undefined) {
|
if (!useSpatialIndex && collection === undefined) {
|
||||||
|
|||||||
Reference in New Issue
Block a user