OpenLayers. Geometry. Collection

A Collection is exactly what it sounds like: A collection of different Geometries.  These are stored in the local parameter components (which can be passed as a parameter to the constructor).

As new geometries are added to the collection, they are NOT cloned.  When removing geometries, they need to be specified by reference (ie you have to pass in the exact geometry to be removed).

The getArea and getLength functions here merely iterate through the components, summing their respective areas and lengths.

Create a new instance with the OpenLayers.Geometry.Collection constructor.

Inerhits from

Summary
OpenLayers. Geometry. CollectionA Collection is exactly what it sounds like: A collection of different Geometries.
Properties
components{Array(OpenLayers.Geometry)} The component parts of this geometry
componentTypes{Array(String)} An array of class names representing the types of components that the collection can include.
Constructor
OpenLayers. Geometry. CollectionCreates a Geometry Collection -- a list of geoms.
Functions
destroyDestroy this geometry.
cloneClone this geometry.
getComponentsStringGet a string representing the components for this collection
calculateBoundsRecalculate the bounds by iterating through the components and calling calling extendBounds() on each item.
addComponentsAdd components to this geometry.
addComponentAdd a new component (geometry) to the collection.
removeComponentsRemove components from this geometry.
removeComponentRemove a component from this geometry.
getLengthCalculate the length of this geometry
getAreaCalculate the area of this geometry.
moveMoves a collection in place
rotateRotate a geometry around some origin
resizeResize a geometry relative to some origin.
equalsTests for equivalent geometries
transformReproject the components geometry from source to dest.
intersectsDetermine if the input geometry intersects this one.

Properties

components

{Array(OpenLayers.Geometry)} The component parts of this geometry

componentTypes

{Array(String)} An array of class names representing the types of components that the collection can include.  A null value means the component types are not restricted.

Constructor

OpenLayers. Geometry. Collection

Creates a Geometry Collection -- a list of geoms.

Parameters

components{Array(OpenLayers.Geometry)} Optional array of geometries

Functions

destroy

destroy: function ()

Destroy this geometry.

clone

clone: function()

Clone this geometry.

Returns

{OpenLayers.Geometry.Collection} An exact clone of this collection

getComponentsString

getComponentsString: function()

Get a string representing the components for this collection

Returns

{String} A string representation of the components of this geometry

calculateBounds

calculateBounds: function()

Recalculate the bounds by iterating through the components and calling calling extendBounds() on each item.

addComponents

addComponents: function(components)

Add components to this geometry.

Parameters

components{Array(OpenLayers.Geometry)} An array of geometries to add

addComponent

addComponent: function(component,
index)

Add a new component (geometry) to the collection.  If this.componentTypes is set, then the component class name must be in the componentTypes array.

The bounds cache is reset.

Parameters

component{OpenLayers.Geometry} A geometry to add
index{int} Optional index into the array to insert the component

Returns

{Boolean} The component geometry was successfully added

removeComponents

removeComponents: function(components)

Remove components from this geometry.

Parameters

components{Array(OpenLayers.Geometry)} The components to be removed

removeComponent

removeComponent: function(component)

Remove a component from this geometry.

Parameters

component{OpenLayers.Geometry}

getLength

getLength: function()

Calculate the length of this geometry

Returns

{Float} The length of the geometry

getArea

getArea: function()

Calculate the area of this geometry.  Note how this function is overridden in OpenLayers.Geometry.Polygon.

Returns

{Float} The area of the collection by summing its parts

move

move: function(x,
y)

Moves a collection in place

Parameters

x{Float} The x-displacement (in map units)
y{Float} The y-displacement (in map units)

rotate

rotate: function(angle,
origin)

Rotate a geometry around some origin

Parameters

angle{Float} Rotation angle in degrees (measured counterclockwise from the positive x-axis)
origin{OpenLayers.Geometry.Point} Center point for the rotation

resize

resize: function(scale,
origin,
ratio)

Resize a geometry relative to some origin.  Use this method to apply a uniform scaling to a geometry.

Parameters

scale{Float} Factor by which to scale the geometry.  A scale of 2 doubles the size of the geometry in each dimension (lines, for example, will be twice as long, and polygons will have four times the area).
origin{OpenLayers.Geometry.Point} Point of origin for resizing
ratio{Float} Optional x:y ratio for resizing.  Default ratio is 1.

equals

equals: function(geometry)

Tests for equivalent geometries

Parameters

geometry{OpenLayers.Geometry}

Returns

{Boolean} The coordinates are equivalent

transform

transform: function(source,
dest)

Reproject the components geometry from source to dest.

Parameters

source{OpenLayers.Projection}
dest{OpenLayers.Projection}

Returns

{OpenLayers.Geometry}

intersects

intersects: function(geometry)

Determine if the input geometry intersects this one.

Parameters

geometry{OpenLayers.Geometry} Any type of geometry.

Returns

{Boolean} The input geometry intersects this one.

A Geometry is a description of a geographic object.
destroy: function ()
Destroy this geometry.
clone: function()
Clone this geometry.
getComponentsString: function()
Get a string representing the components for this collection
calculateBounds: function()
Recalculate the bounds by iterating through the components and calling calling extendBounds() on each item.
addComponents: function(components)
Add components to this geometry.
addComponent: function(component,
index)
Add a new component (geometry) to the collection.
removeComponents: function(components)
Remove components from this geometry.
removeComponent: function(component)
Remove a component from this geometry.
getLength: function()
Calculate the length of this geometry
getArea: function()
Calculate the area of this geometry.
move: function(x,
y)
Moves a collection in place
rotate: function(angle,
origin)
Rotate a geometry around some origin
resize: function(scale,
origin,
ratio)
Resize a geometry relative to some origin.
equals: function(geometry)
Tests for equivalent geometries
transform: function(source,
dest)
Reproject the components geometry from source to dest.
intersects: function(geometry)
Determine if the input geometry intersects this one.
{Array(OpenLayers.Geometry)} The component parts of this geometry
Creates a Geometry Collection -- a list of geoms.
Polygon is a collection of Geometry.LinearRings.
Point geometry class.
Class for coordinate transforms between coordinate systems.
Close