Class: GeometryCollection

ol/geom/GeometryCollection~GeometryCollection


import GeometryCollection from 'ol/geom/GeometryCollection.js';

Geometry 对象的数组。

new GeometryCollection(geometries)

Name Type Description
geometries Array<Geometry>

几何对象数组。

触发事件:

Extends

Methods

applyTransform(transformFn)

对几何对象的坐标应用变换函数。几何对象会被原地修改。如果不想原地修改几何对象,请先 clone() 然后对副本使用此函数。

Name Type Description
transformFn Transform函数

变换函数。以几何坐标的扁平数组作为参数调用。

增加修订计数器并派发 'change' 事件。

创建几何对象的完整副本。

Returns:
副本。

dispatchEvent(event){boolean | undefined} inherited

分发事件并调用所有监听此类型事件的监听器。事件参数可以是字符串或具有 type 属性的对象。

Name Type Description
event BaseEvent | string

事件对象。

Returns:
false if anyone called preventDefault on the event object or if any of the listeners returned false.

获取一个值。

Name Type Description
key string

键名。

Returns:
值。

getClosestPoint(point, closestPoint){Coordinate} inherited

返回几何对象到传入点的最近点,作为 坐标

Name Type Description
point Coordinate

点。

closestPoint Coordinate | undefined

最近点。

Returns:
最近点。

获取几何对象的范围。

Name Type Description
extent Extent | undefined

范围。

Returns:
范围。

getGeometries(){Array<Geometry>}

返回组成此几何对象集合的几何对象。

Returns:
几何对象数组。

getKeys(){Array.<string>} inherited

获取对象属性名列表。

Returns:
属性名列表。

getProperties(){NoInfer.<Properties>} inherited

获取所有属性名和值的对象。

Returns:
对象。

getRevision(){number} inherited

获取此对象的版本号。每次对象被修改时,版本号会递增。

Returns:
修订版本。

获取此几何对象的类型。

Returns:
几何对象类型。

intersectsCoordinate(coordinate){boolean} inherited

如果此几何对象包含指定坐标则返回 true。如果坐标在几何对象的边界上,则返回 false。

Name Type Description
coordinate Coordinate

坐标。

Returns:
包含坐标。

intersectsExtent(extent){boolean}

测试几何对象与传入的范围是否相交。

Name Type Description
extent Extent

范围。

Returns:
true 如果几何对象与范围相交。

on(type, listener){EventsKey | Array<EventsKey>} inherited

监听特定类型的事件。

Name Type Description
type string | Array.<string>

事件类型或事件类型数组。

listener function

监听函数。

Returns:
监听器的唯一键。如果第一个参数是事件类型数组,则返回键的数组。

once(type, listener){EventsKey | Array<EventsKey>} inherited

监听一次特定类型的事件。

Name Type Description
type string | Array.<string>

事件类型或事件类型数组。

listener function

监听函数。

Returns:
监听器的唯一键。如果第一个参数是事件类型数组,则返回键的数组。

rotate(angle, anchor)

围绕给定坐标旋转几何图形。此方法就地修改几何坐标。

Name Type Description
angle number

逆时针旋转角度(弧度)。

anchor Coordinate

旋转中心。

scale(sx, sy, anchor)

缩放几何对象(可选原点)。这会原地修改几何对象坐标。

Name Type Description
sx number

x 方向的缩放因子。

sy number | undefined

y 方向的缩放因子(默认为 sx)。

anchor Coordinate | undefined

缩放原点(默认为几何对象范围的中心)。

set(key, value, silent) inherited

设置一个值。

Name Type Description
key string

键名。

value *

值。

silent boolean | undefined

更新而不触发事件。

setGeometries(geometries)

设置组成此几何对象集合的几何对象。

Name Type Description
geometries Array<Geometry>

几何对象数组。

setProperties(values, silent) inherited

设置一组键值对。注意这会更改现有属性并添加新属性(不会移除任何现有属性)。

Name Type Description
values Partial.<NoInfer.<Properties>>

值。

silent boolean | undefined

更新而不触发事件。

创建此几何对象的简化版本。对于线字符串,使用 Douglas Peucker 算法。对于多边形,使用基于量化的简化来保持拓扑。

Name Type Description
tolerance number

简化的容差距离。

Returns:
原始几何对象的新的简化版本。

transform(source, destination){this} inherited

将几何对象的每个坐标从一个坐标参考系统变换到另一个。几何对象会被原地修改。例如,线会变换为线,圆会变换为圆。如果不想原地修改几何对象,请先 clone() 然后对副本使用此函数。

Name Type Description
source ProjectionLike

当前投影。可以是字符串标识符或 Projection 对象。

destination ProjectionLike

目标投影。可以是字符串标识符或 Projection 对象。

Returns:
此几何对象。注意原始几何对象会被原地修改。

translate(deltaX, deltaY)

平移几何对象。这会原地修改几何对象坐标。如果想要新的几何对象,请先 clone() 此几何对象。

Name Type Description
deltaX number

X 方向偏移量。

deltaY number

Y 方向偏移量。

un(type, listener) inherited

取消监听特定类型的事件。

Name Type Description
type string | Array.<string>

事件类型或事件类型数组。

listener function

监听函数。

unset(key, silent) inherited

取消设置一个属性。

Name Type Description
key string

键名。

silent boolean | undefined

取消设置但不触发事件。