Class: IWBounds

IWBounds

A class representing a rectangle defined by two coordinates in opposite corners. To calculate the zoom level to show this rectangle in a map use IWMap.getBoundsZoomlevel().

Example:
var berlin = new IWCoordinate(13.376469, 52.516186, IWCoordinate.WGS84).toMercator();
var dortmund = new IWCoordinate(7.457671, 51.517039, IWCoordinate.WGS84).toMercator();
var bonn = new IWCoordinate(7.101044, 50.732725, IWCoordinate.WGS84).toMercator();

var bounds = new IWBounds(berlin, dortmund);
bounds.extendBy(bonn);
// Alternative: var bounds = new IWBounds( [berlin, dortmund, bonn] );

map.setCenter(bounds.getCenter(), map.getBoundsZoomlevel(bounds));

new IWBounds(first, second)

Creates a new rectangle defined by the specified coordinates.
Parameters:
Name Type Description
first IWCoordinate the first corner of the rectangle, or an array of coordinates
second IWCoordinate the second corner of the rectangle (optional, only if first parameter is a coordinate)

Methods


clone(other)

Returns a copy of the bounds object with the same values
Parameters:
Name Type Description
other IWBounds another bounds object
Returns:
Type
boolean

contains(other)

Checks whether the specified rectangle is contained in this one.
Parameters:
Name Type Description
other IWBounds another rectangle
Returns:
Type
boolean

containsCoordinate(coord)

Checks whether the specified coordinate is contained in this rectangle.
Parameters:
Name Type Description
coord IWCoordinates a coordinate
Returns:
Type
boolean

equals(other)

Checks whether the specified rectangle and this one are the same.
Parameters:
Name Type Description
other IWBounds another rectangle
Returns:
Type
boolean

extendBy(coord)

Extends this rectangle by the specified coordinate or bounds.
Parameters:
Name Type Description
coord IWCoordinates a coordinate or IWBounds object
Returns:
Type
void

getCenter()

Returns the center of this rectangle as a coordinate.
Returns:
Type
IWCoordinates

getMax()

Returns the maximum coordinate of this rectangle (larger values for x and y).
Returns:
Type
IWCoordinates

getMin()

Returns the minimum coordinate of this rectangle (smaller values for x and y).
Returns:
Type
IWCoordinates

getNorthWest()

Returns the coordinate in the north west corner of this rectangle.
Deprecated:
  • Use getMin() instead
Returns:
Type
IWCoordinates

getSize()

Returns the size of this rectangle.
Returns:
Type
IWSize

getSouthEast()

Returns the coordinate in the south east corner of this rectangle.
Deprecated:
  • Use getMax() instead
Returns:
Type
IWCoordinates

intersects(other)

Checks whether this rectangle intersects another one.
Parameters:
Name Type Description
other IWBounds another rectangle
Returns:
Type
boolean

isEmpty()

Checks whether this rectangle is empty, i.e. the north west and the south east coordinates are the same.
Returns:
Type
boolean

toString()

Returns a string representation of this rectangle.
Returns:
Type
String