util.bounds

Static object.

Set of statistical methods for working with rectangular areas, represented as two opposite points in the coordinate system of the projection.

Methods

Methods

Name Returns Description
areIntersecting(bounds1, bounds2[, projection])

Boolean

Determines whether two rectangular areas intersect.

containsBounds(outer, inner[, projection])

Boolean

Determines whether a rectangular area completely contains another rectangular area.

containsPoint(bounds, point[, projection])

Boolean

Determines whether a rectangular area contains a point.

fromBounds(sourceBounds[, projection])

Number[][]

Calculates the rectangular area that everything passed falls inside of.

fromGlobalPixelBounds(pixelBounds, zoom[, projection])

Number[][]

Converts a rectangular area from pixel coordinates to geo coordinates with the zoom factor taken into account.

fromPoints(points[, projection])

Number[][]

Calculates the minimal rectangular area that contains all the passed points.

getCenter(bounds[, projection])

Number[]

Calculates the center of a rectangular area in the coordinate system of the projection.

getCenterAndZoom(bounds, containerSize[, projection[, params]])

Object

Calculates the center and zoom that should be set for the map in order to display the passed area in its entirety.

getIntersections(bounds1, bounds2[, projection])

Number[][][]

Returns all intersections of two rectangular areas. If data is passed in geo coordinates, there may be more than one intersection. If the areas do not intersect, an empty array is returned.

getSize(bounds[, projection])

Number[]

Calculates the dimensions of a rectangular area in the coordinate system of the projection.

toGlobalPixelBounds(geoBounds, zoom[, projection])

Number[][]

Converts boundaries from geo coordinates to global pixels, accounting for the zoom level.

Methods details

areIntersecting

{Boolean} areIntersecting(bounds1, bounds2[, projection])

Determines whether two rectangular areas intersect.

Returns intersection attribute.

Parameters:

Parameter Default value Description
bounds1 *

Type: Number[][]

First area.

bounds2 *

Type: Number[][]

Second area.

projection projection.wgs84Mercator

Type: IProjection

Projection.

* Mandatory parameter/option.

containsBounds

{Boolean} containsBounds(outer, inner[, projection])

Determines whether a rectangular area completely contains another rectangular area.

Returns inclusion attribute.

Parameters:

Parameter Default value Description
outer *

Type: Number[][]

External area

inner *

Type: Number[][]

The area being checked.

projection projection.wgs84Mercator

Type: IProjection

Projection.

* Mandatory parameter/option.

containsPoint

{Boolean} containsPoint(bounds, point[, projection])

Determines whether a rectangular area contains a point.

Returns inclusion attribute.

Parameters:

Parameter Default value Description
bounds *

Type: Number[][]

External area

point *

Type: Number[]

The point being checked.

projection projection.wgs84Mercator

Type: IProjection

Projection.

* Mandatory parameter/option.

fromBounds

{Number[][]} fromBounds(sourceBounds[, projection])

Calculates the rectangular area that everything passed falls inside of.

Returns the calculated area.

Parameters:

Parameter Default value Description
sourceBounds *

Type: Number[][][]

Array of rectangular areas

projection projection.wgs84Mercator

Type: IProjection

Projection.

* Mandatory parameter/option.

fromGlobalPixelBounds

{Number[][]} fromGlobalPixelBounds(pixelBounds, zoom[, projection])

Converts a rectangular area from pixel coordinates to geo coordinates with the zoom factor taken into account.

Returns calculated boundaries in geo coordinates.

Parameters:

Parameter Default value Description
pixelBounds *

Type: Number[][]

Original boundaries.

zoom *

Type: Number

Scale.

projection projection.wgs84Mercator

Type: IProjection

The projection that will be used for claculating geo coordinates.

* Mandatory parameter/option.

fromPoints

{Number[][]} fromPoints(points[, projection])

Calculates the minimal rectangular area that contains all the passed points.

Returns the calculated area.

Parameters:

Parameter Default value Description
points *

Type: Number[][]

Array of points.

projection projection.wgs84Mercator

Type: IProjection

Projection.

* Mandatory parameter/option.

getCenter

{Number[]} getCenter(bounds[, projection])

Calculates the center of a rectangular area in the coordinate system of the projection.

Returns center point in the coordinate system of the input data.

Parameters:

Parameter Default value Description
bounds *

Type: Number[][]

Area.

projection projection.wgs84Mercator

Type: IProjection

Projection.

* Mandatory parameter/option.

getCenterAndZoom

{Object} getCenterAndZoom(bounds, containerSize[, projection[, params]])

Calculates the center and zoom that should be set for the map in order to display the passed area in its entirety.

Returns object with the center (Number[]) and zoom (Number) fields.

Parameters:

Parameter Default value Description
bounds *

Type: Number[][]

An area set in geographical coordinates. The first point contains the minimum values for latitude and longitude, and the second point contains the maximum values.

containerSize *

Type: Number[]

Size of the map container.

projection projection.wgs84Mercator

Type: IProjection

Projection.

params

Type: Boolean|Object

Parameters or value of the preciseZoom option.

params.inscribe true

Type: Boolean

If true, fit the area into the map; if false, fit the map into the area.

params.margin 0

Type: Number|Number[]

Offset from the borders of the visible area of the map. If a single number is set, it is applied to each side. If two numbers are set, they are the horizontal and vertical margins, respectively. If an array of four numbers is set, they are the top, right, bottom, and left margins.

params.preciseZoom false

Type: Boolean

When the value is "false", the zoom level is rounded down.

* Mandatory parameter/option.

getIntersections

{Number[][][]} getIntersections(bounds1, bounds2[, projection])

Returns all intersections of two rectangular areas. If data is passed in geo coordinates, there may be more than one intersection. If the areas do not intersect, an empty array is returned.

Parameters:

Parameter Default value Description
bounds1 *

Type: Number[][]

First area.

bounds2 *

Type: Number[][]

Second area.

projection projection.wgs84Mercator

Type: IProjection

Projection.

* Mandatory parameter/option.

getSize

{Number[]} getSize(bounds[, projection])

Calculates the dimensions of a rectangular area in the coordinate system of the projection.

Returns size of the area.

Parameters:

Parameter Default value Description
bounds *

Type: Number[][]

Area.

projection projection.wgs84Mercator

Type: IProjection

Projection.

* Mandatory parameter/option.

toGlobalPixelBounds

{Number[][]} toGlobalPixelBounds(geoBounds, zoom[, projection])

Converts boundaries from geo coordinates to global pixels, accounting for the zoom level.

Returns resulting pixel boundaries.

Parameters:

Parameter Default value Description
geoBounds *

Type: Number[][]

Original boundaries.

zoom *

Type: Number

Scale.

projection projection.wgs84Mercator

Type: IProjection

The projection in the coordinate system that the geo coordinates are set in.

* Mandatory parameter/option.