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.

Summary

OpenLayers. Geometry. Collection | A 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. Collection | Creates a Geometry Collection -- a list of geoms. |

Functions | |

destroy | Destroy this geometry. |

clone | Clone this geometry. |

getComponentsString | Get a string representing the components for this collection |

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

addComponents | Add components to this geometry. |

addComponent | Add a new component (geometry) to the collection. |

removeComponents | Remove components from this geometry. |

removeComponent | Remove a component from this geometry. |

getLength | Calculate the length of this geometry |

getArea | Calculate the area of this geometry. |

getGeodesicArea | Calculate the approximate area of the polygon were it projected onto the earth. |

getCentroid | Compute the centroid for this geometry collection. |

getGeodesicLength | Calculate the approximate length of the geometry were it projected onto the earth. |

move | Moves a geometry by the given displacement along positive x and y axes. |

rotate | Rotate a geometry around some origin |

resize | Resize a geometry relative to some origin. |

distanceTo | Calculate the closest distance between two geometries (on the x-y plane). |

equals | Determine whether another geometry is equivalent to this one. |

transform | Reproject the components geometry from source to dest. |

intersects | Determine if the input geometry intersects this one. |

getVertices | Return a list of all points in this geometry. |

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

Creates a Geometry Collection -- a list of geoms.

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

clone: function()

Clone this geometry.

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

addComponents: function( components )

Add components to this geometry.

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

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.

component | {OpenLayers.Geometry} A geometry to add |

index | {int} Optional index into the array to insert the component |

{Boolean} The component geometry was successfully added

removeComponents: function( components )

Remove components from this geometry.

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

removeComponent: function( component )

Remove a component from this geometry.

component | {OpenLayers.Geometry} |

getArea: function()

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

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

getGeodesicArea: function( projection )

Calculate the approximate area of the polygon were it projected onto the earth.

projection | {OpenLayers.Projection} The spatial reference system for the geometry coordinates. If not provided, Geographic/WGS84 is assumed. |

Robert. G. Chamberlain and William H. Duquette, “Some Algorithms for Polygons on a Sphere”, JPL Publication 07-03, Jet Propulsion Laboratory, Pasadena, CA, June 2007 http://trs-new.jpl.nasa.gov- /dspace- /handle- /2014- /40409

{float} The approximate geodesic area of the geometry in square meters.

getCentroid: function( weighted )

Compute the centroid for this geometry collection.

weighted | {Boolean} Perform the getCentroid computation recursively, returning an area weighted average of all geometries in this collection. |

{OpenLayers.Geometry.Point} The centroid of the collection

getGeodesicLength: function( projection )

Calculate the approximate length of the geometry were it projected onto the earth.

projection | {OpenLayers.Projection} The spatial reference system for the geometry coordinates. If not provided, Geographic/WGS84 is assumed. |

{Float} The appoximate geodesic length of the geometry in meters.

rotate: function( angle, origin )

Rotate a geometry around some origin

angle | {Float} Rotation angle in degrees (measured counterclockwise from the positive x-axis) |

origin | {OpenLayers.Geometry.Point} Center point for the rotation |

resize: function( scale, origin, ratio )

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

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. |

{OpenLayers.Geometry} | The current geometry. |

distanceTo: function( geometry, options )

Calculate the closest distance between two geometries (on the x-y plane).

geometry | {OpenLayers.Geometry} The target geometry. |

options | {Object} Optional properties for configuring the distance calculation. |

details | {Boolean} Return details from the distance calculation. Default is false. |

edge | {Boolean} Calculate the distance from this geometry to the nearest edge of the target geometry. Default is true. If true, calling distanceTo from a geometry that is wholly contained within the target will result in a non-zero distance. If false, whenever geometries intersect, calling distanceTo will return 0. If false, details cannot be returned. |

{Number | Object} The distance between this geometry and the target. If details is true, the return will be an object with distance, x0, y0, x1, and y1 properties. The x0 and y0 properties represent the coordinates of the closest point on this geometry. The x1 and y1 properties represent the coordinates of the closest point on the target geometry.

equals: function( geometry )

Determine whether another geometry is equivalent to this one. Geometries are considered equivalent if all components have the same coordinates.

geom | {OpenLayers.Geometry} The geometry to test. |

{Boolean} The supplied geometry is equivalent to this geometry.

transform: function( source, dest )

Reproject the components geometry from source to dest.

source | {OpenLayers.Projection} |

dest | {OpenLayers.Projection} |

intersects: function( geometry )

Determine if the input geometry intersects this one.

geometry | {OpenLayers.Geometry} Any type of geometry. |

{Boolean} The input geometry intersects this one.

getVertices: function( nodes )

Return a list of all points in this geometry.

nodes | {Boolean} For lines, only return vertices that are endpoints. If false, for lines, only vertices that are not endpoints will be returned. If not provided, all vertices will be returned. |

{Array} A list of all vertices in the geometry.

A Geometry is a description of a geographic object.

Destroy this geometry.

destroy: function ()

Clone this geometry.

clone: function()

Get a string representing the components for this collection

getComponentsString: function()

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

calculateBounds: function()

Add components to this geometry.

addComponents: function( components )

Add a new component (geometry) to the collection.

addComponent: function( component, index )

Remove components from this geometry.

removeComponents: function( components )

Remove a component from this geometry.

removeComponent: function( component )

Calculate the length of this geometry

getLength: function()

Calculate the area of this geometry.

getArea: function()

Calculate the approximate area of the polygon were it projected onto the earth.

getGeodesicArea: function( projection )

Compute the centroid for this geometry collection.

getCentroid: function( weighted )

Calculate the approximate length of the geometry were it projected onto the earth.

getGeodesicLength: function( projection )

Moves a geometry by the given displacement along positive x and y axes.

move: function( x, y )

Rotate a geometry around some origin

rotate: function( angle, origin )

Resize a geometry relative to some origin.

resize: function( scale, origin, ratio )

Calculate the closest distance between two geometries (on the x-y plane).

distanceTo: function( geometry, options )

Determine whether another geometry is equivalent to this one.

equals: function( geometry )

Reproject the components geometry from source to dest.

transform: function( source, dest )

Determine if the input geometry intersects this one.

intersects: function( geometry )

Return a list of all points in this geometry.

getVertices: function( nodes )

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

Creates a Geometry Collection -- a list of geoms.

Polygon is a collection of Geometry.LinearRings.

Class for coordinate transforms between coordinate systems.

Point geometry class.