//Identify queryfunction initidentify () {require (["Esri/map","esri/infotemplate","Esri/layers/arcgisdynamicmapservicelayer","Esri/symbols/simplefillsymbol","Esri/symbols/simplelinesymbol","Esri/tasks/identifytask","esri/tasks/identifyparameters","Esri/dijit/popup","Dojo/_base/array","Esri/color","dojo/dom-construct","dojo/domready!"], function (Map, infotemplate, Arcgisdynamicmapservicelayer, Simplefillsymbol,simplelinesymbol, Identifytask , Identifyparameters, Popup,arrayutils, Color, domconstruct) {varIdentifyurl ="Http://119.163.121.32:6080/arcgis/rest/services/kjgk/MapServer"; Identifytask=NewIdentifytask (Identifyurl); Identifyparams=Newidentifyparameters (); Identifyparams.tolerance=3; Identifyparams.returngeometry=true; Identifyparams.layerids= [0,1,2,3]; Identifyparams.layeroption=Identifyparameters.layer_option_all; Identifyparams.width=Map.width; Identifyparams.height=Map.height; Map.on ("Click", doidentify); function Doidentify (Event) { //Identify's geometryIdentifyparams.geometry =Event. MapPoint; //Identify rangeIdentifyparams.mapextent =map.extent; varDeferred =Identifytask.execute (identifyparams). Addcallback (function (response) {returnArrayutils.map (response, function (result) {varFeature =result.feature; varLayerName =Result.layername; Feature.attributes.layerName=LayerName; if(LayerName = = ='sde.heat') { varHeattemplate =NewInfotemplate ("Property Information", "Mine number:${kjbh}</br> mine name:${kjmc}</br> mine type: ${KJLX}"); Feature.setinfotemplate (heattemplate); } Else if(LayerName = = ='Sde.geo') { varGeoTemplate =NewInfotemplate ("Property Information","Item No: ${BH}"); Feature.setinfotemplate (GeoTemplate); } Else if(LayerName = = ='SDE.DH') { varDhtemplate =NewInfotemplate ("Property Information","Item No: ${id}"); Feature.setinfotemplate (dhtemplate); } Else if(LayerName = = ='SDE.CKQ') { varCkqtemplate =NewInfotemplate ("Property Information","Item No: ${KJBH}"); Feature.setinfotemplate (ckqtemplate); } returnfeature; }); }); Map.infoWindow.setFeatures ([deferred]); Map.infoWindow.show (Event. MapPoint); } });}
Event-triggered invocation.
ArcGIS API for JavaScript learning Identifytask