Namespace: geometry

Description

The esri.geometry namespace has several utility methods associated with it. These methods are convenience methods that are not associated with any class.

Samples

Search for samples that use this class.  

Methods

Method Return Value Description
esri.geometry.fromJson(json) Object Converts the input JSON object to the appropriate esri.geometry.* object.
esri.geometry.geographicToWebMercator(geometry) Geometry Converts geometry from geographic units to Web Mercator units.
esri.geometry.getExtentForScale(map, scale) Extent Get the extent for the specified scale.
esri.geometry.getJsonType(geometry) String Requests the geometry type name as represented in the ArcGIS REST.
esri.geometry.getLength(point1, point2) Number Calculates the length of a line based on the input of two points.
esri.geometry.getLineIntersection(line1start, line1end, line2start, line2end) Point Calculates the intersecting point of two lines. If the lines are parallel, a null value is returned.
esri.geometry.getScale(map) Number Gets the current scale of the map.
esri.geometry.isClockwise() Boolean Checks if a Polygon ring is clockwise. Returns true for clockwise and false for counterclockwise.
esri.geometry.toMapGeometry(extent, width, height, mapGeometry) Geometry Converts the geometry argument to map coordinates based on the extent, width, and height of the Map.
esri.geometry.toMapPoint(extent, width, height, screenPoint) Point Converts and returns the argument screen point in map coordinates. Deprecated at v1.1. Use toMapGeometry instead.
esri.geometry.toScreenGeometry(extent, width, height, screenGeometry) Geometry Converts the geometry argument to screen coordinates based on the extent, width, and height of the Map.
esri.geometry.toScreenPoint(extent, width, height, mapPoint) Point Converts and returns the argument map point in screen coordinates. Deprecated at v1.1. Use toScreenGeometry instead.
esri.geometry.webMercatorToGeographic(geometry) Geometry Converts geometry from Web Mercator units to geographic units.
Methods Detail

esri.geometry.fromJson(json)

Converts the input JSON object to the appropriate esri.geometry.* object.
Return value: Object
Input Parameters:
<Object> json Required The JSON object.

esri.geometry.geographicToWebMercator(geometry)

Converts geometry from geographic units to Web Mercator units. (As of v1.4)
Return value: Geometry
Input Parameters:
<Geometry> geometry Required The geometry to convert.
Code snippets:
 var geom = esri.geometry.geographicToWebMercator(candidate.location);

esri.geometry.getExtentForScale(map, scale)

Get the extent for the specified scale.
Return value: Extent
Input Parameters:
<Map> map Required The input map.
<Number> scale Required The input scale.
Code snippets:
  var extent =  esri.geometry.getExtentForScale(map,10000);

esri.geometry.getJsonType(geometry)

Requests the geometry type name as represented in the ArcGIS REST.
Return value: String
Input Parameters:
<Geometry> geometry Required The ArcGIS JavaScript API geometry type to be converted.

esri.geometry.getLength(point1, point2)

Calculates the length of a line based on the input of two points.
Return value: Number
Input Parameters:
<Point> point1 Required The beginning point.
<Point> point2 Required The ending point.

esri.geometry.getLineIntersection(line1start, line1end, line2start, line2end)

Calculates the intersecting point of two lines. If the lines are parallel, a null value is returned.
Return value: Point
Input Parameters:
<Point> line1start Required The beginning point of the first line.
<Point> line1end Required The ending point of the first line.
<Point> line2start Required The beginning point of the second line.
<Point> line2end Required The ending point of the second line.

esri.geometry.getScale(map)

Gets the current scale of the map.

Version history:

  • Originally added v1.4 with input parameters of extent,mapWidth,wkid
  • Input paramters modified at v2.0, now only the map is required.

(As of v1.4)
Return value: Number
Input Parameters:
<Map> map Required The map whose scale should be calculated.
Code snippets:
  var scale = esri.geometry.getScale(map);

esri.geometry.isClockwise()

Checks if a Polygon ring is clockwise. Returns true for clockwise and false for counterclockwise.
Return value: Boolean

esri.geometry.toMapGeometry(extent, width, height, mapGeometry)

Converts the geometry argument to map coordinates based on the extent, width, and height of the Map. (As of v1.1)
Return value: Geometry
Input Parameters:
<Extent> extent Required The current extent of the map in map coordinates.
<Number> width Required The current width of the map in map units.
<Number> height Required The current width of the map in map units.
<Geometry> mapGeometry Required The geometry to convert from screen to map units.

esri.geometry.toMapPoint(extent, width, height, screenPoint)

Converts and returns the argument screen point in map coordinates. Deprecated at v1.1. Use toMapGeometry instead.
Return value: Point
Input Parameters:
<Extent> extent Required The current extent of the map in map coordinates.
<Number> width Required The current width of the map in screen units.
<Number> height Required The current width of the map in screen units.
<Point> screenPoint Required The point to convert from screen to map units.

esri.geometry.toScreenGeometry(extent, width, height, screenGeometry)

Converts the geometry argument to screen coordinates based on the extent, width, and height of the Map. (As of v1.1)
Return value: Geometry
Input Parameters:
<Extent> extent Required The current extent of the map in map coordinates.
<Number> width Required The current width of the map in screen units.
<Number> height Required The current width of the map in screen units.
<Geometry> screenGeometry Required The geometry to convert from map to screen units.

esri.geometry.toScreenPoint(extent, width, height, mapPoint)

Converts and returns the argument map point in screen coordinates. Deprecated at v1.1. Use toScreenGeometry instead.
Return value: Point
Input Parameters:
<Extent> extent Required The current extent of the map in map coordinates.
<Number> width Required The current width of the map in screen units.
<Number> height Required The current width of the map in screen units.
<Point> mapPoint Required The point to convert from map to screen units.

esri.geometry.webMercatorToGeographic(geometry)

Converts geometry from Web Mercator units to geographic units. (As of v1.4)
Return value: Geometry
Input Parameters:
<Geometry> geometry Required The geometry to convert.
Code snippets:
query.geometry = esri.geometry.webMercatorToGeographic(geometries[0]);