Identify Tool (IdentifyTask)

09-29-2015 05:38 AM
New Contributor II

I am trying to popup an InfoWindow when user click on visible layer after selecting Identify Tool  from the menu as shown in the attached image.

I followed this example URL(Display identify results in popup | ArcGIS API for JavaScript )  from ESRI officail website and coded so far as below but not succeeded yet. It is showing "map.infoWindow.setFeatures" is not a function" error.

Please help me to solve this problem. Please find the code in the attachment.

<!DOCTYPE html>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <!--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="">
      html, body, #map {height:100%;width:100%;margin:0;padding:0;}
    <script src=""></script>
      var map;
      var identifyListener;

      ], function (
        Map, FeatureLayer, InfoWindow, InfoTemplate, ArcGISDynamicMapServiceLayer, SimpleFillSymbol,
        SimpleLineSymbol, IdentifyTask, IdentifyParameters, FloatingPane, Popup,
        arrayUtils, Color, domConstruct, dom, on
      ) {
        var identifyTask, identifyParams;
  var infoWindow = new InfoWindow({}, domConstruct.create("div"));
        var popup = new Popup({
          fillSymbol: new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
            new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
              new Color([255, 0, 0]), 2), new Color([255, 255, 0, 0.25]))
        }, domConstruct.create("div"));

        map = new Map("map", {
          basemap: "satellite",
          center: [84.0000, 20.1500],
          zoom: 7,
   infoWindow: infoWindow
        map.on("load", mapReady);
        var stateLayerURL = ""; 
        map.addLayer(new ArcGISDynamicMapServiceLayer(stateLayerURL,
          { opacity: 0.55 }));
        function mapReady () {
          //map.on("click", executeIdentifyTask);
  on(dom.byId("identifyMe"), "click", function(evt){
  identifyListener = dojo.connect(map, "onClick", executeIdentifyTask);
  //create identify tasks and setup parameters
  identifyTask = new IdentifyTask(stateLayerURL);

  identifyParams = new IdentifyParameters();
  identifyParams.tolerance = 3;
  identifyParams.returnGeometry = true;
  identifyParams.layerIds = [6];
  identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_TOP;
  identifyParams.width = map.width;
  identifyParams.height = map.height;

        function executeIdentifyTask (event) {
          identifyParams.geometry = event.mapPoint;
          identifyParams.mapExtent = map.extent;
          var deferred = identifyTask
            .addCallback(function (response) {
              // response is an array of identify result objects
              // Let's return an array of features.
              return, function (result) {
                var feature = result.feature;
                var layerName = result.layerName;

                feature.attributes.layerName = layerName;

  var taxParcelTemplate = new InfoTemplate("${S_NAME}", "Tractors : ${TRACTORS_2012}");
                return feature;
    <button id="identifyMe">Identify</button>
    <div id="map">
Tags (2)
0 Kudos
6 Replies
MVP Esteemed Contributor


  Your issue is that you are setting the maps infowindow to a infoWindow object and that does not have a setFeatures function. You will notice in the sample you began with they are setting the maps infoWindow to a Popup dijit and the popup dijit does have a setFeatures function.

So just change the map constructor to this:

      map = new Map("map", {
        basemap: "satellite",
        center: [84.0000, 20.1500],
        zoom: 7,
        infoWindow: popup
0 Kudos
New Contributor II

Thanks Robert fro your reply but actually I want to use InfoWindow instead of popup. So do you have any idea how to do that ?

0 Kudos
MVP Regular Contributor

I think what you are trying to do is setContent InfoWindow | API Reference | ArcGIS API for JavaScript

New Contributor II

When I am using setContent() its showing error.

0 Kudos
MVP Esteemed Contributor


  If you are wanting to use InfoWindow then you have to manually add your content to the InfoWindow and can not take advantage of the way the sample demos using a defered. You would have to use the infoWindows setContent method and manually show the infoWindow using the show method from the Identify Task result handler.

New Contributor II

Can you give me any example code or demo app for reference.

I want exactly the same way how Identify tool is working in this video.

v1 - ArcGIS Javascript API, Identify, Hyperlink manager, Spatial Queries - YouTube


0 Kudos