Defaults for the Layer, Source and Feature generics
This commit is contained in:
@@ -11,7 +11,7 @@ import {listen, unlistenByKey} from './events.js';
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Feature<import("./geom/Geometry.js").default>|import("./render/Feature.js").default} FeatureLike
|
* @typedef {Feature|import("./render/Feature.js").default} FeatureLike
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/***
|
/***
|
||||||
@@ -70,7 +70,7 @@ import {listen, unlistenByKey} from './events.js';
|
|||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
* @template {import("./geom/Geometry.js").default} Geometry
|
* @template {import("./geom/Geometry.js").default} [Geometry=import("./geom/Geometry.js").default]
|
||||||
*/
|
*/
|
||||||
class Feature extends BaseObject {
|
class Feature extends BaseObject {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1007,8 +1007,7 @@ function createFeatureStyleFunction(
|
|||||||
if (drawName) {
|
if (drawName) {
|
||||||
const geometry = feature.getGeometry();
|
const geometry = feature.getGeometry();
|
||||||
if (geometry) {
|
if (geometry) {
|
||||||
const type = geometry.getType();
|
if (geometry instanceof GeometryCollection) {
|
||||||
if (type === GeometryType.GEOMETRY_COLLECTION) {
|
|
||||||
multiGeometryPoints = geometry
|
multiGeometryPoints = geometry
|
||||||
.getGeometriesArrayRecursive()
|
.getGeometriesArrayRecursive()
|
||||||
.filter(function (geometry) {
|
.filter(function (geometry) {
|
||||||
@@ -1020,6 +1019,7 @@ function createFeatureStyleFunction(
|
|||||||
});
|
});
|
||||||
drawName = multiGeometryPoints.length > 0;
|
drawName = multiGeometryPoints.length > 0;
|
||||||
} else {
|
} else {
|
||||||
|
const type = geometry.getType();
|
||||||
drawName =
|
drawName =
|
||||||
type === GeometryType.POINT || type === GeometryType.MULTI_POINT;
|
type === GeometryType.POINT || type === GeometryType.MULTI_POINT;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ class Polyline extends TextFeature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import("../Feature.js").default} feature Features.
|
* @param {import("../Feature.js").default<LineString>} feature Features.
|
||||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||||
* @protected
|
* @protected
|
||||||
* @return {string} Text.
|
* @return {string} Text.
|
||||||
@@ -126,7 +126,7 @@ class Polyline extends TextFeature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Array<import("../Feature.js").default>} features Features.
|
* @param {Array<import("../Feature.js").default<LineString>>} features Features.
|
||||||
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
* @param {import("./Feature.js").WriteOptions} [opt_options] Write options.
|
||||||
* @protected
|
* @protected
|
||||||
* @return {string} Text.
|
* @return {string} Text.
|
||||||
|
|||||||
@@ -421,7 +421,7 @@ class Draw extends PointerInteraction {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sketch feature.
|
* Sketch feature.
|
||||||
* @type {Feature}
|
* @type {Feature<import('../geom/SimpleGeometry.js').default>}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.sketchFeature_ = null;
|
this.sketchFeature_ = null;
|
||||||
@@ -1022,7 +1022,7 @@ class Draw extends PointerInteraction {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop drawing without adding the sketch feature to the target layer.
|
* Stop drawing without adding the sketch feature to the target layer.
|
||||||
* @return {Feature} The sketch feature (or null if none).
|
* @return {Feature<import("../geom/SimpleGeometry.js").default>} The sketch feature (or null if none).
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
abortDrawing_() {
|
abortDrawing_() {
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ class Modify extends PointerInteraction {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Editing vertex.
|
* Editing vertex.
|
||||||
* @type {Feature}
|
* @type {Feature<Point>}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.vertexFeature_ = null;
|
this.vertexFeature_ = null;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import {listen, unlistenByKey} from '../events.js';
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @template {import("../source/Source.js").default} SourceType
|
* @template {import("../source/Source.js").default} [SourceType=import("../source/Source.js").default]
|
||||||
* @typedef {Object} Options
|
* @typedef {Object} Options
|
||||||
* @property {string} [className='ol-layer'] A CSS class name to set to the layer element.
|
* @property {string} [className='ol-layer'] A CSS class name to set to the layer element.
|
||||||
* @property {number} [opacity=1] Opacity (0, 1).
|
* @property {number} [opacity=1] Opacity (0, 1).
|
||||||
@@ -93,8 +93,8 @@ import {listen, unlistenByKey} from '../events.js';
|
|||||||
* @fires import("../render/Event.js").RenderEvent#prerender
|
* @fires import("../render/Event.js").RenderEvent#prerender
|
||||||
* @fires import("../render/Event.js").RenderEvent#postrender
|
* @fires import("../render/Event.js").RenderEvent#postrender
|
||||||
*
|
*
|
||||||
* @template {import("../source/Source.js").default} SourceType
|
* @template {import("../source/Source.js").default} [SourceType=import("../source/Source.js").default]
|
||||||
* @template {import("../renderer/Layer.js").default} RendererType
|
* @template {import("../renderer/Layer.js").default} [RendererType=import("../renderer/Layer.js").default]
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class Layer extends BaseLayer {
|
class Layer extends BaseLayer {
|
||||||
|
|||||||
@@ -96,8 +96,9 @@ function getRenderExtent(frameState, extent) {
|
|||||||
fromUserExtent(layerState.extent, frameState.viewState.projection)
|
fromUserExtent(layerState.extent, frameState.viewState.projection)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const source =
|
const source = /** @type {import("../../source/Tile.js").default} */ (
|
||||||
/** {import("../../source/Tile.js").default} */ layerState.layer.getRenderSource();
|
layerState.layer.getRenderSource()
|
||||||
|
);
|
||||||
if (!source.getWrapX()) {
|
if (!source.getWrapX()) {
|
||||||
const gridExtent = source
|
const gridExtent = source
|
||||||
.getTileGridForProjection(frameState.viewState.projection)
|
.getTileGridForProjection(frameState.viewState.projection)
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ class Cluster extends VectorSource {
|
|||||||
this.geometryFunction =
|
this.geometryFunction =
|
||||||
options.geometryFunction ||
|
options.geometryFunction ||
|
||||||
function (feature) {
|
function (feature) {
|
||||||
const geometry = feature.getGeometry();
|
const geometry = /** @type {Point} */ (feature.getGeometry());
|
||||||
assert(geometry.getType() == GeometryType.POINT, 10); // The default `geometryFunction` can only handle `Point` geometries
|
assert(geometry.getType() == GeometryType.POINT, 10); // The default `geometryFunction` can only handle `Point` geometries
|
||||||
return geometry;
|
return geometry;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import {xhr} from '../featureloader.js';
|
|||||||
* @classdesc
|
* @classdesc
|
||||||
* Events emitted by {@link module:ol/source/Vector} instances are instances of this
|
* Events emitted by {@link module:ol/source/Vector} instances are instances of this
|
||||||
* type.
|
* type.
|
||||||
* @template {import("../geom/Geometry.js").default} Geometry
|
* @template {import("../geom/Geometry.js").default} [Geometry=import("../geom/Geometry.js").default]
|
||||||
*/
|
*/
|
||||||
export class VectorSourceEvent extends Event {
|
export class VectorSourceEvent extends Event {
|
||||||
/**
|
/**
|
||||||
@@ -170,7 +170,7 @@ export class VectorSourceEvent extends Event {
|
|||||||
*
|
*
|
||||||
* @fires VectorSourceEvent
|
* @fires VectorSourceEvent
|
||||||
* @api
|
* @api
|
||||||
* @template {import("../geom/Geometry.js").default} Geometry
|
* @template {import("../geom/Geometry.js").default} [Geometry=import("../geom/Geometry.js").default]
|
||||||
*/
|
*/
|
||||||
class VectorSource extends Source {
|
class VectorSource extends Source {
|
||||||
/**
|
/**
|
||||||
@@ -299,9 +299,15 @@ class VectorSource extends Source {
|
|||||||
|
|
||||||
let collection, features;
|
let collection, features;
|
||||||
if (Array.isArray(options.features)) {
|
if (Array.isArray(options.features)) {
|
||||||
features = options.features;
|
features =
|
||||||
|
/** @type {Array<import("../Feature.js").default<Geometry>>} */ (
|
||||||
|
options.features
|
||||||
|
);
|
||||||
} else if (options.features) {
|
} else if (options.features) {
|
||||||
collection = options.features;
|
collection =
|
||||||
|
/** @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