An example of ArcGIS javascript API identify query function
<! Doctype HTML>
<HTML>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<Meta http-equiv = "X-UA-compatible" content = "Ie = 7, ie = 9, ie = 10">
<! -- The viewport meta tag is used to improve the presentation and behavior of the samples
On iOS devices -->
<Meta name = "viewport" content = "Initial-scale = 1, maximum-scale = 1, user-scalable = No">
<Title> identify with popup </title>
<LINK rel = "stylesheet" href = "http://serverapi.arcgisonline.com/jsapi/arcgis/3.4/js/esri/css/esri.css">
<Style>
HTML, body, # map {
Height: 100%;
Width: 100%;
Margin: 0;
Padding: 0;
}
</Style>
<SCRIPT> var dojoconfig = {parseonload: true}; </SCRIPT>
<SCRIPT src = "http://serverapi.arcgisonline.com/jsapi/arcgis/3.4/"> </SCRIPT>
<SCRIPT>
Dojo. Require ("ESRI. Map ");
Dojo. Require ("ESRI. dijit. Popup ");
VaR map;
VaR identifytask, identifyparams;
Function Init (){
// Setup the popup window
VaR popup = new ESRI. dijit. Popup ({
Fillsymbol: New ESRI. symbol. simplefillsymbol (ESRI. symbol. simplefillsymbol. style_solid, new ESRI. symbol. simplelinesymbol (ESRI. symbol. simplelinesymbol. style_solid, new dojo. color ([255, 0]), 2), new dojo. color ([255,255, 0, 0.25])
}, Dojo. Create ("Div "));
Map = new ESRI. Map ("map ",{
Basemap: "satellite ",
Center: [-83.275, 42.573],
Zoom: 18,
Infowindow: popup
});
Dojo. Connect (MAP, "onLoad", mapready );
VaR landbaselayer = new ESRI. layers. arcgisdynamicmapservicelayer ("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer", {opacity:. 55 });
Map. addlayer (landbaselayer );
}
Function mapready (MAP ){
Dojo. Connect (MAP, "onclick", executeidentifytask );
// Create identify tasks and setup Parameters
Identifytask = new ESRI. Tasks. identifytask ("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer ");
Identifyparams = new ESRI. Tasks. identifyparameters ();
Identifyparams. Tolerance = 3;
Identifyparams. returngeometry = true;
Identifyparams. layerids = [0, 2];
Identifyparams. layeroption = ESRI. Tasks. identifyparameters. layer_option_all;
Identifyparams. width = map. width;
Identifyparams. Height = map. height;
}
Function executeidentifytask (EVT ){
Identifyparams. Geometry = EVT. mappoint;
Identifyparams. mapextent = map. extent;
VaR deferred = identifytask.exe cute (identifyparams );
Deferred. addcallback (function (response ){
// Response is an array of identify result objects
// Let's return an array of features.
Return dojo. Map (response, function (result ){
VaR feature = result. feature;
Feature. Attributes. layername = result. layername;
If (result. layername = 'tax parcels '){
Console. Log (feature. Attributes. parcelid );
VaR template = new ESRI. infotemplate ("", "$ {postal address} <br/> owner of record: $ {first owner name }");
Feature. setinfotemplate (Template );
}
Else if (result. layername = 'Building footprints '){
VaR template = new ESRI. infotemplate ("", "parcel ID :$ {parcelid }");
Feature. setinfotemplate (Template );
}
Return feature;
});
});
// Infowindow expects an array of features from each deferred
// Object that you pass. If the response from the task execution
// Above is not an array of features, then you need to add a callback
// Like the one above to post-process the response and return
// Array of features.
Map. infowindow. setfeatures ([deferred]);
Map. infowindow. Show (EVT. mappoint );
}
Dojo. Ready (init );
</SCRIPT>
</Head>
<Body>
<Div id = "map"> </div>
</Body>
</Html>