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.
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 |
Constructor | |
OpenLayers. Geometry. Collection | Creates a Geometry Collection -- a list of geoms. |
Functions | |
destroy | Destroy this geometry. |
clone | Clone this geometry. |
calculateBounds | Recalculate the bounds by iterating through the components and calling calling extendBounds() on each item. |
addComponents | Add components to this geometry. |
removeComponents | Remove components from this geometry. |
getLength | Calculate the length of this geometry |
getArea | Calculate the area of this geometry. |
move | Moves a collection in place |
rotate | Rotate a geometry around some origin |
resize | Resize a geometry relative to some origin. |
equals | Tests for equivalent geometries |
transform | Reproject the components geometry from source to dest. |
intersects | 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.
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 |
removeComponents: function( components )
Remove components from this geometry.
components | {Array(OpenLayers.Geometry)} The components to be removed |
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
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. |
equals: function( geometry )
Tests for equivalent geometries
geometry | {OpenLayers.Geometry} |
{Boolean} The coordinates are equivalent
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.
Destroy this geometry.
destroy: function ()
Clone this geometry.
clone: 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 )
Remove components from this geometry.
removeComponents: function( components )
Calculate the length of this geometry
getLength: function()
Calculate the area of this geometry.
getArea: function()
Moves a collection in place
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 )
Tests for equivalent geometries
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 )