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
A Collection is exactly what it sounds like: A collection of different Geometries.
{Array(OpenLayers.Geometry)} The component parts of this geometry
Creates a Geometry Collection -- a list of geoms.
Destroy this geometry.
Clone this geometry.
Recalculate the bounds by iterating through the components and calling calling extendBounds() on each item.
Add components to this geometry.
Remove components from this geometry.
Calculate the length of this geometry
Calculate the area of this geometry.
Moves a collection in place
Rotate a geometry around some origin
Resize a geometry relative to some origin.
Tests for equivalent geometries

Properties

components

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

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

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

removeComponents

removeComponents: function(components)

Remove components from this geometry.

Parameters

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

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)

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

equals

equals: function(geometry)

Tests for equivalent geometries

Parameters

geometry{OpenLayers.Geometry}

Returns

{Boolean} The coordinates are equivalent

A Geometry is a description of a geographic object.
destroy: function ()
Destroy this geometry.
clone: function()
Clone this geometry.
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.
removeComponents: function(components)
Remove components 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)
Resize a geometry relative to some origin.
equals: function(geometry)
Tests for equivalent geometries
{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.