Hide Table of Contents
esri
Map
toolbars
Class: Extent
[ AMD Module Require | Legacy Module Require ]

Description

The minimum and maximum X- and Y- coordinates of a bounding box.

Samples

Search for samples that use this class.

Class hierarchy

esri.geometry.Geometry
|_esri.geometry.Extent

Constructors

ConstructorDescription
new esri.geometry.Extent(xmin,ymin,xmax,ymax,spatialReference)Creates a new Extent object. The coordinates represent the lower left and upper right corners of the bounding box. A spatial reference is also required.
new esri.geometry.Extent(json)Creates a new Extent object using a JSON object.

Properties

PropertyTypeDescription
spatialReferenceSpatialReferenceThe spatial reference of the geometry. See Projected Coordinate Systems and Geographic Coordinate Systems for the list of supported spatial references.
typeStringThe type of geometry.
xmaxNumberTop-right X-coordinate of an extent envelope.
xminNumberBottom-left X-coordinate of an extent envelope.
ymaxNumberTop-right Y-coordinate of an extent envelope.
yminNumberBottom-left Y-coordinate of an extent envelope.

Methods

MethodReturn ValueDescription
centerAt(point)ExtentA new extent is returned with the same width and height centered at the argument point.
contains(geometry)BooleanWhen "true", the geometry in the argument is contained in this extent.
expand(factor)ExtentExpands the extent by the factor given. For example, a value of 1.5 will be 50% bigger.
getCenter()PointReturns the center point of the extent in map units.
getHeight()NumberDistance between ymin and ymax.
getWidth()NumberDistance between xmin and xmax.
intersects(geometry)Extent | BooleanReturns the interesection extent if the input geometry is an extent that intersects this extent. Boolean is returned when passing in non-Extent geometry types.
offset(dx,dy)ExtentOffsets the current extent. Units are map units.
setSpatialReference(sr)GeometrySets the spatial reference.

The return value of Geometry was added at v1.4.
toJson()ObjectConverts object to its ArcGIS Server JSON representation.
union(extent)ExtentExpands this extent to include the extent of the argument.
update(xmin,ymin,xmax,ymax,spatialReference)ExtentUpdates this extent with the specified parameters.

The return value of Extent was added at v1.4.
Constructor Details

new esri.geometry.Extent(xmin,ymin,xmax,ymax,spatialReference)

Creates a new Extent object. The coordinates represent the lower left and upper right corners of the bounding box. A spatial reference is also required.
Parameters:
<Number> xminRequiredBottom-left X-coordinate of an extent envelope.
<Number> yminRequiredBottom-left Y-coordinate of an extent envelope.
<Number> xmaxRequiredTop-right X-coordinate of an extent envelope.
<Number> ymaxRequiredTop-right Y-coordinate of an extent envelope.
<SpatialReference> spatialReferenceRequiredSpatial reference of the geometry.
Code Snippet:
var extent = new esri.geometry.Extent(-122.68,45.53,-122.45,45.60, new esri.SpatialReference({ wkid:4326 }));

new esri.geometry.Extent(json)

Creates a new Extent object using a JSON object.
Parameters:
<Object> jsonRequiredJSON object representing the geometry.
Code Snippet:
var extent = new esri.geometry.Extent({"xmin":-122.68,"ymin":45.53,"xmax":-122.45,"ymax":45.6,
  "spatialReference":{"wkid":4326}});
Property Details

<SpatialReference> spatialReference

The spatial reference of the geometry. See Projected Coordinate Systems and Geographic Coordinate Systems for the list of supported spatial references.

<String> type

The type of geometry.
Known Values: point | multipoint | polyline | polygon | extent

<Number> xmax

Top-right X-coordinate of an extent envelope.

<Number> xmin

Bottom-left X-coordinate of an extent envelope.

<Number> ymax

Top-right Y-coordinate of an extent envelope.

<Number> ymin

Bottom-left Y-coordinate of an extent envelope.
Method Details

centerAt(point)

A new extent is returned with the same width and height centered at the argument point.
Return Value: Extent
Input Parameters:
<Point> pointRequiredCenters the extent on the specified x,y location.

contains(geometry)

When "true", the geometry in the argument is contained in this extent.
Return Value: Boolean
Input Parameters:
<Geometry> geometryRequiredCan be a Point or Extent.

Prior to version 2.0, the first parameter was

<Point> point Required When "true", the point in the argument is contained in this extent.
Code Snippet:
var extent = map.extent;
if(extent.contains(graphic.geometry)) {
  graphic.setSymbol(highlightSymbol);
}

expand(factor)

Expands the extent by the factor given. For example, a value of 1.5 will be 50% bigger.
Return Value: Extent
Input Parameters:
<Number> factorRequiredThe multiplier value.
Code Snippet:
map.setExtent(points.getExtent().expand(3));

getCenter()

Returns the center point of the extent in map units.
Return Value: Point

getHeight()

Distance between ymin and ymax.
Return Value: Number

getWidth()

Distance between xmin and xmax.
Return Value: Number

intersects(geometry)

Returns the interesection extent if the input geometry is an extent that intersects this extent. Boolean is returned when passing in non-Extent geometry types.
Return Value: Extent | Boolean
Input Parameters:
<Geometry> geometryRequiredThe geometry used to test the intersection. Valid geometry includes Point, Multipoint, Extent, Polygon, or Polyline.

Prior to version 2.0, the first parameter was

<Extent> extent Required The minx, miny, maxx, and maxy bounding box.
Code Snippet:
var polygonExtent = polygon.getExtent();
if (polygonExtent.intersects(map.extent)) {
  alert("Polygon intersects current map extent");
}

offset(dx,dy)

Offsets the current extent. Units are map units.
Return Value: Extent
Input Parameters:
<Number> dxRequiredThe offset distance in map units for the y-coordinate.
<Number> dyRequiredThe offset distance in map units for the x-coordinate.

setSpatialReference(sr)

Sets the spatial reference.

The return value of Geometry was added at v1.4.
Return Value: Geometry
Input Parameters:
<SpatialReference> srRequiredSpatial reference of the geometry.

toJson()

Converts object to its ArcGIS Server JSON representation.
Return Value: Object

union(extent)

Expands this extent to include the extent of the argument.
Return Value: Extent
Input Parameters:
<Extent> extentRequiredThe minx, miny, maxx, and maxy bounding box.

update(xmin,ymin,xmax,ymax,spatialReference)

Updates this extent with the specified parameters.

The return value of Extent was added at v1.4.
Return Value: Extent
Input Parameters:
<Number> xminRequiredBottom-left X-coordinate of an extent envelope.
<Number> yminRequiredBottom-left Y-coordinate of an extent envelope.
<Number> xmaxRequiredTop-right X-coordinate of an extent envelope.
<Number> ymaxRequiredTop-right Y-coordinate of an extent envelope.
<SpatialReference> spatialReferenceRequiredSpatial reference of the geometry.