Class: Extent

Extent

Represent a bounding box on the map, a rectangular geographical area with minimum and maximum coordinates.
There are serveral ways to create a extent:

new Extent(x1, y1, x2, y2) [source]

//with 4 numbers: xmin, ymin, xmax and ymax
var extent = new Extent(100, 10, 120, 20);
//with 2 coordinates
var extent = new Extent(new Coordinate(100, 10), new Coordinate(120, 20));
//with a json object containing xmin, ymin, xmax and ymax
var extent = new Extent({xmin : 100, ymin: 10, xmax: 120, ymax:20});
var extent1 = new Extent(100, 10, 120, 20);
//with another extent
var extent2 = new Extent(extent1);
Parameter Type Description
x1 Number x of coordinate 1
y1 Number y of coordinate 1
x2 Number x of coordinate 2
y2 Number y of coordinate 2

Members

  • xmin

  • Properties:
    Name Type Description
    xmin Number minimum x
    Source:

  • xmax

  • Properties:
    Name Type Description
    xmax Number maximum x
    Source:

  • ymin

  • Properties:
    Name Type Description
    ymin Number minimum y
    Source:

  • ymax

  • Properties:
    Name Type Description
    ymax Number maximum y
    Source:

    Methods

  • add(p) [source]

  • Add the extent with a coordinate or a point.
    Parameter Type Description
    p Coordinate | Point point or coordinate to add
    Returns:
    Extent: a new extent
  • sub(p) [source]

  • Substract the extent with a coordinate or a point.
    Parameter Type Description
    p Coordinate | Point point or coordinate to substract
    Returns:
    Extent: a new extent
  • substract(p) [source]

  • Alias for sub
    Parameter Type Description
    p Coordinate | Point point or coordinate to substract
    Returns:
    Extent: a new extent
  • round() [source]

  • Round the extent
    Returns:
    Extent: rounded extent
  • getMin() [source]

  • Get the minimum point
    Returns:
    Coordinate:
  • getMax() [source]

  • Get the maximum point
    Returns:
    Coordinate:
  • getCenter() [source]

  • Get center of the extent.
    Returns:
    Coordinate:
  • (protected) isValid() [source]

  • Whether the extent is valid
    Returns:
    Boolean:
  • equals(ext2) [source]

  • Compare with another extent to see whether they are equal.
    Parameter Type Description
    ext2 Extent extent to compare
    Returns:
    Boolean:
  • intersects(ext2) [source]

  • Whether it intersects with another extent
    Parameter Type Description
    ext2 Extent another extent
    Returns:
    Boolean:
  • within(ext2) [source]

  • Whether the extent is within another extent
    Parameter Type Description
    ext2 Extent another extent
    Returns:
    Boolean:
  • contains(coordinate) [source]

  • Whether the extent contains the input point.
    Parameter Type Description
    coordinate Coordinate | Array.<Number> input point
    Returns:
    Boolean:
  • getWidth() [source]

  • Get the width of the Extent
    Returns:
    Number:
  • getHeight() [source]

  • Get the height of the Extent
    Returns:
    Number:
  • getSize() [source]

  • Get size of the Extent
    Returns:
    Size:
  • combine(extent) [source]

  • Combine it with another extent to a larger extent.
    Parameter Type Description
    extent Extent | Coordinate | Point extent/coordinate/point to combine into
    Returns:
    Extent: extent combined
  • intersection(extent) [source]

  • Gets the intersection extent of this and another extent.
    Parameter Type Description
    extent Extent another extent
    Returns:
    Extent: intersection extent
  • expand(distance) [source]

  • Expand the extent by distance
    Parameter Type Description
    distance Size | Number distance to expand
    Returns:
    Extent: a new extent expanded from
  • toJSON() [source]

  • Get extent's JSON object.
    // {xmin : 100, ymin: 10, xmax: 120, ymax:20}
    var json = extent.toJSON();
    Returns:
    Object: jsonObject
  • toArray() [source]

  • Get a coordinate array of extent's rectangle area, containing 5 coordinates in which the first equals with the last.
    Returns:
    Array.<Coordinate>: coordinates array
  • copy() [source]

  • Get a copy of the extent.
    Returns:
    Extent: copy
  • convertTo(fn) [source]

  • Convert to a new extent
    Parameter Type Description
    fn function convert function on each point
    Returns:
    Extent: