Skip to content

Instantly share code, notes, and snippets.

raykendo /
Last active Jul 6, 2018
ArcGIS-JSAPI: Clicking on a webmap without clicking on a webmap

Clicking on a map without clicking on a map

An ArcGIS JavaScript API hack

Purpose: I have a map application with a list of results from a query. When I click on one of the items in the result list, I wanted the map to zoom to the associated feature, and trigger a click that shows the result in a popup.

Library: ArcGIS JavaScript API

Version: tested on versions 3.9-3.13.

raykendo / arcgis-jsapi-ondrawbegin.js
Last active Aug 29, 2015
ArcGIS-JSAPI: DrawingToolbar hack for onDrawBegin
View arcgis-jsapi-ondrawbegin.js
* Making up for a missing "draw-begin" or "draw-start" event for the ArcGIS JavaScript API Drawing toolbar
* Problem: While the drawing toolbar in the ArcGIS JavaScript API has a "draw-end" and a "draw-complete"
* event, it doesn't have a "draw-start" or "draw-begin" event.
* Solution: Use a dojo/on pausable event that is only unpaused after the draw-end event.
require(["esri/map", "dojo/on", "esri/toolbars/draw"], function (Map, dojoOn, Draw) {
var map = new Map("mapdiv", {});
raykendo / gist:31fb197a3f1a1ba52a6f
Created May 25, 2015
ArcGIS JSAPI: Query Distinct, the old fashion way.
View gist:31fb197a3f1a1ba52a6f
require([..., "esri/tasks/query", "esri/tasks/QueryTask", "dojo/_base/array",...],
function (..., Query, QueryTask, arrayUtils,...) {
// urls faked to protect the innocent kitties
var qTask = new QueryTask(""),
query = new Query();
// set up the parameters to query for the breeds
query.where = "1=1";
query.outFields = ["breed"];
query.returnGeometry = false;
raykendo / gist:507839766456f90e76d6
Created May 25, 2015
ArcGIS JSAPI: Query Return Distinct - Quick and Dirty (V. < 3.11)
View gist:507839766456f90e76d6
require(["esri/tasks/QueryTask"], function (QueryTask) {
var url = "",
qTask = new QueryTask(url + "?returnDistinctValues=true");
raykendo / gist:a107b9417d62839a02c5
Last active Aug 29, 2015
ArcGIS JSAPI: Query Return Distinct - Precallback Request (V < 3.11)
View gist:a107b9417d62839a02c5
require(["esri/request"], function (esriRequest) {
// test if we're sending the request to a mapservice query
// if not requesting ObjectIds, count, or querying with a list of ObjectIDs, return distinct values.
if (ioArgs.content && !ioArgs.content.returnIdsOnly && !ioArgs.content.returnCountOnly && !ioArgs.content.objectIds) {
ioArgs.content.returnDistinctValues = true;
return ioArgs;
raykendo / arcgis-jsapi-map-zoom-in-closer.js
Created May 29, 2015
ArcGIS JSAPI: Map with ESRI basemap zooming in closer than basemap allows.
View arcgis-jsapi-map-zoom-in-closer.js
require(["esri/Map"], function (Map) {
var map = new Map("mapdiv", {
basemap: "streets",
center: [-15.469, 36.428]
lods: [
// level: 0,
// resolution: 156543.033928,
// scale: 591657527.591555
raykendo / conf.xml
Created Jun 4, 2015
ArcGIS Server Tiled Map Service conf.xml for ESRI/Google/Bing Map Scales + 1:500 and 1:250-ish scales
View conf.xml
<?xml version="1.0" encoding="utf-8" ?>
<CacheInfo xsi:type='typens:CacheInfo' xmlns:xsi='' xmlns:xs='' xmlns:typens=''>
<TileCacheInfo xsi:type='typens:TileCacheInfo'>
<SpatialReference xsi:type='typens:ProjectedCoordinateSystem'>
raykendo / arcgis-jsapi-webmap-extra-zoom-levels.js
Created Jun 9, 2015
ArcGIS JSAPI: AGOL Webmap with extra zoom levels
View arcgis-jsapi-webmap-extra-zoom-levels.js
require(["esri/arcgis/utils"], function (arcgisUtils) {
// borrowed webmap id from
arcgisUtils.createMap("c41d5f3b4e304806a047702fbfc2759e", "mapdiv", {
usePopupManager: true, // just tossed this in there to show other webmap options
mapOptions: {
basemap: "streets",
center: [-15.469, 36.428]
lods: [
// level: 0,
raykendo / customMeasurementDijit.js
Last active Aug 29, 2015
ArcGIS JSAPI: Measurement + Popup Combo
View customMeasurementDijit.js
* Custom Measurement Widget extension that connects to Popup dijit (esri/dijit/Popup),
* retrieves the selected feature, then passes the geometry to be measured by the Measurement Dijit.
raykendo / BigQueryTask.js
Last active Jul 4, 2018
ArcGIS JSAPI Hack - Getting around the 1000 results limit for queries
View BigQueryTask.js
/** globals define */
], function (
declare, Deferred, Query, QueryTask, esriRequest
) {