| Property | Type | Description |
|---|---|---|
| config | Object | ArcGIS JavaScript API default configurations that can be overridden programatically. For details, see Default API configurations. |
| documentBox | Object | Represents the size of the client side window or document at first load. The size contains width and height properties, and these do not change on window resize. |
| version | Number | Current version of the JavaScript API. |
| Method | Return Value | Description |
|---|---|---|
| esri.filter(object, callback, thisObject) | Object | Creates a new object with all properties that pass the test implemented by the filter provided in the function. |
| esri.getGeometries(graphics) | Geometry[] | Converts an array of graphics to an array of geometries. This is primarily used by GeometryService. Beginning with version 2.0, GeometryService accepts only geometries and not graphics. |
| esri.graphicsExtent(graphics) | Extent | Utility function that returns the extent of an array of graphics. If the extent height and width are 0, null is returned. |
| esri.hide(element) | none | Hides an HTML element such as a DIV or TABLE. |
| esri.request(request, options?, useProxy?) | dojo.Deferred | A wrapper around dojo.io.script.get and dojo.xhrPost. Use this method to request data from a server. This method uses a proxy for large requests, starting at version 1.3 setting useProxy to true will force it to use a proxy. At 2.1 useProxy was added to an options argument that allows you to specify the useProxy and usePost options. This method includes a default error handler in cases when the server response is an error. The returned object is dojo.Deferred. |
| esri.setRequestPreCallback(callbackFunction) | none | Define a callback function that will be called just before esri.request calls into dojo IO functions such as dojo.rawXhrPost and dojo.io.script.get. It provides developers an opportunity to modify the request. |
| esri.show(element) | none | Shows an HTML element such as a DIV or TABLE. |
| esri.substitute(data, template?, first?) | String | A wrapper around dojo.string.substitute that can also handle wildcard substitution. A wildcard uses the format of ${*}. If no template is provided, it is assumed to be a wildcard. This method is useful if you are not using Graphic or an InfoTemplate, but you want to embed result values in HTML, for example. |
| esri.toggle(element) | none | If an HTML element is currently visible, the element is hidden. If the element is hidden, it becomes visible. |
| esri.urlToObject(url) | Object | Converts the URL arguments to an object representation. The object format is
{path: <String>, query:{key:<Object>}} |
| esri.valueOf(array, value) | Object | Iterates through the argument array and searches for the identifier to which the argument value matches. Returns null if no matching identifier is found. |
| <Object> object | Required | Object to filter. |
| <Function> callback | Required | Function or string implementing the filtering. |
| <Object> thisObject | Required | Optional object used to scope the call to the callback. |
function showResults(results) {
var filterFunction = function(value) {
if ((value !== ' ') & (Number(value) !== 0)) {
return true;
}
};
var filteredResults = esri.filter(results.features[0].attributes, filterFunction);
var s = "";
for (att in filteredResults) {
s = s + "" + att + ": " + filteredResults[att] + "
";
}
dojo.byId("info").innerHTML = s;
}
GeometryService accepts only geometries and not graphics. (As of v2.0)| <Graphic[]> graphics | Required | Array of graphics to convert to geometries |
geometries[0] = esri.getGeometries(baseGraphics);
| <Graphics> graphics | Required | The input graphics array. |
var myFeatureExtent = esri.graphicsExtent(myFeatureSet.features);
| <Element> element | Required | The name of the HTML element. |
esri.hide(myTable);
| <Object> request | Required | The request object. |
| <Object> options | Optional |
The options argument, added at 2.1 to replace useProxy, has the following properties:
{
useProxy: <Boolean>,
usePost: <Boolean>
}
When useProxy is set to true it forces the request to be posted through the proxy. Setting usePost to true indicates that the request should use the HTTP POST method. If the request URL is from another origin the proxy will be used. |
| <Boolean> useProxy | Optional | When true, it forces a request to be posted through the proxy even if the content length is less than 2k. (As of v1.3) Starting with version 2.1 and greater use the options argument instead. |
Pre-2.1 sample
var requestHandle = esri.request({
url: url.path,
content: url.query,
handleAs: "text",
load: requestSucceeded,
error: requestFailed
}, true);
Post 2.1 sample
var requestHandle = esri.request({
url: url.path,
content: url.query,
handleAs: "text",
load: requestSucceeded,
error: requestFailed
}, {useProxy:true});
| <Function> callbackFunction | Required | The callback function that wil be executed prior to esri.request calls into dojo IO functions. |
function myCallbackFunction(ioArgs) {
// inspect ioArgs
console.log(ioArgs.url, ioArgs.content);
// or, change some query parameters if necessary
ioArgs.content = ioArgs.content || {};
ioArgs.content.token = "ABCDEF123456";
// don't forget to return ioArgs.
return ioArgs;
}
// where the argument ioArgs is of type: dojo.__XhrArgs (or) dojo.io.script.__ioArgs
esri.setRequestPreCallback(myCallbackFunction);
| <Element> element | Required | The name of the HTML element. |
esri.show(myDiv);
${*}. If no template is provided, it is assumed to be a wildcard. This method is useful if you are not using Graphic or an InfoTemplate, but you want to embed result values in HTML, for example.| <Object> data | Required | The data object used in the substitution. |
| <String> template | Optional | The template used for the substitution. Can be any valid HTML. If no template is included, the wildcard template is used. |
| <Boolean> first | Optional | When true, returns only the first property found in the data object. The default is false. |
Example 1: no wildcard is included but is assumed.
esri.substitute({state_name: "Arizona", state_capital: "Phoenix"});
Returns: state_name = Arizona <br/> state_capital = PHoenix
Example 2: no wildcard is included and only the first property is displayed.
esri.substitute({state_name: "Arizona", state_capital: "Phoenix"},null,true);
Returns: state_name = Arizona <br/>
Example 3: a template is included for display.
esri.substitute({state_name: "Arizona", state_capital: "Phoenix"},"The capital of ${state_name} is ${state_capital}.");
Returns: The capital of Arizona is Phoenix.
| <Element> element | Required | The name of the HTML element. |
{path: <String>, query:{key:<Object>}}| <String> url | Required | The input URL. |
var myObject = esri.urlToObject("http://www.myworld.com?state_name=Ohio&city_name=Akron");
Returns: { path: "http://www.myworld.com", query: {state_name: "Ohio", city_name: "Akron"} }
If there are no query parameters the return value for query will be null: {path:"http://www.myworld.com",query:null}
The following snippet shows how to check for null or undefined values.
var myObject = esri.urlToObject("http://www.myworld.com");
if(myObject.query){
var query = myObject.query;
}
| <Array> array | Required | The argument array for testing. |
| <Object> value | Required | The value used in the search. If the value is a String, the value is case sensitive. |
Example 1:
esri.valueOf([firststring: "Oregon", secondstring: "Washington"], "Washington");
Returns: secondstring
Example 2:
esri.valueOf([firststring: "Oregon", secondstring: "Washington"], "Virginia");
Returns: null