Hide Table of Contents
esri/dijit/util
esri/layer/pixelFilters
esri/process
esri/workers
Object: esri/geometry/scaleUtils

require(["esri/geometry/scaleUtils"], function(scaleUtils) { /* code goes here */ });

Description

(Added at v3.8)
Utility methods to get map scale or extent for a given scale.

When coding legacy (non-AMD) style, there is no need to require the module. All methods and properties are available in the namespace. For example, esri.geometry.getExtentForScale().

Samples

Search for samples that use this class.

Methods

NameReturn typeSummary
getExtentForScale(map, scale)ExtentGet the extent for the specified scale.
getScale(map)NumberGets the current scale of the map.
getUnitValueForSR(sr)NumberReturns the value of one map unit for the given spatial reference (in meters).
Method Details

getExtentForScale(map, scale)

Get the extent for the specified scale.
Return type: Extent
Parameters:
<Map> map Required The input map.
<Number> scale Required The input scale.
Sample:
require([
  "esri/geometry/scaleUtils", ... 
], function(scaleUtils, ... ) {
  var extent = scaleUtils.getExtentForScale(map, 10000);
  ...
});

getScale(map)

Gets the current scale of the map.
Return type: Number
Parameters:
<Map> map Required The map whose scale should be calculated.
Sample:
require([
  "esri/geometry/scaleUtils", ... 
], function(scaleUtils, ... ) {
  var scale = scaleUtils.getScale(map);
  ...
});

getUnitValueForSR(sr)

Returns the value of one map unit for the given spatial reference (in meters). The sr parameter can be a SpatialReference, WKID, or WKT. See Projected Coordinate Systems and Geographic Coordinate Systems for the list of supported spatial references. (Added at v3.13)
Return type: Number
Parameters:
<SpatialReference | Number | String> sr Required The spatial reference represented as a SpatialReference class, Number, or String.
Sample:
require([
  "esri/geometry/scaleUtils", ... 
], function(scaleUtils, ... ) {
  var mapUnit = scaleUtils.getUnitValueForSR(map.spatialReference);
  ...
});