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
Name |
Returns |
Description |
Boolean |
Determines whether two rectangular areas intersect. |
|
Boolean |
Determines whether a rectangular area completely contains another rectangular area. |
|
Boolean |
Determines whether a rectangular area contains a point. |
|
Number[][] |
Calculates the rectangular area that everything passed falls inside of. |
|
Number[][] |
Converts a rectangular area from pixel coordinates to geo coordinates with the zoom factor taken into account. |
|
Number[][] |
Calculates the minimal rectangular area that contains all the passed points. |
|
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. |
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. |
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 |
— |
Type: Number[][] First area. |
|
— |
Type: Number[][] Second area. |
|
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 |
— |
Type: Number[][] External area |
|
— |
Type: Number[][] The area being checked. |
|
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 |
— |
Type: Number[][] External area |
|
— |
Type: Number[] The point being checked. |
|
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 |
— |
Type: Number[][][] Array of rectangular areas |
|
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 |
— |
Type: Number[][] Original boundaries. |
|
|
— |
Type: Number Scale. |
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 |
— |
Type: Number[][] Array of points. |
|
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 |
— |
Type: Number[][] Area. |
|
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 |
— |
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. |
|
— |
Type: Number[] Size of the map container. |
|
Type: IProjection Projection. |
||
— |
Type: Boolean|Object Parameters or value of the preciseZoom option. |
|
true |
Type: Boolean If true, fit the area into the map; if false, fit the map into the area. |
|
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. |
|
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 |
— |
Type: Number[][] First area. |
|
— |
Type: Number[][] Second area. |
|
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 |
— |
Type: Number[][] Area. |
|
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 |
— |
Type: Number[][] Original boundaries. |
|
|
— |
Type: Number Scale. |
Type: IProjection The projection in the coordinate system that the geo coordinates are set in. |
* Mandatory parameter/option.
Mandatory parameter/option.