Documentation
Reference
2.1.50 (current version)
collection
interactivityModel
Interfaces
2.1.51 (release candidate)
collection
interactivityModel
Interfaces

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

util.bounds()

Methods

NameReturnsDescription
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:

ParameterDefault valueDescription
bounds1*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Number[][]

First area.

bounds2*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

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:

ParameterDefault valueDescription
outer*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Number[][]

External area

inner*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

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:

ParameterDefault valueDescription
bounds*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Number[][]

External area

point*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

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:

ParameterDefault valueDescription
sourceBounds*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

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:

ParameterDefault valueDescription
pixelBounds*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Number[][]

Original boundaries.

zoom*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

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:

ParameterDefault valueDescription
points*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

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:

ParameterDefault valueDescription
bounds*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

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:

ParameterDefault valueDescription
bounds*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

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*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

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:

ParameterDefault valueDescription
bounds1*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Number[][]

First area.

bounds2*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

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:

ParameterDefault valueDescription
bounds*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

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:

ParameterDefault valueDescription
geoBounds*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Number[][]

Original boundaries.

zoom*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Number

Scale.

projection projection.wgs84Mercator

Type: IProjection

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

* Mandatory parameter/option.