IdentifyCallback / ExecuteIdentifyTask not returning results

2751
5
12-15-2015 07:19 AM
tylerjones1
New Contributor

I am trying to display a popup based on the identify module. For some reason, my identify task is not returning results. Here is the code:

executeIdentifyTask: function (evt) {

            this.previewMode = false;  

            this.map.infoWindow.hide();

            this.map.infoWindow.clearFeatures();

            // don't identify on shift-click, ctrl-click or alt-click

            if (evt.shiftKey || evt.ctrlKey || evt.altKey) {

                return;

            }

            var mapPoint = evt.mapPoint;

            var identifyParams = this.createIdentifyParams(mapPoint);

            var identifies = [];

            var identifiedlayers = [];

            var selectedLayer = this.getSelectedLayer();

            array.forEach(this.layers, lang.hitch(this, function (layer) {

                var layerIds = this.getLayerIds(layer, selectedLayer);

                if (layerIds.length > 0) {

                    var params = lang.clone(identifyParams);

                    params.layerDefinitions = layer.ref.layerDefinitions;

                    params.layerIds = layerIds;

                    identifies.push(layer.identifyTask.execute(params));

                    identifiedlayers.push(layer);

                }

            }));

            if (identifies.length > 0) {

                this.map.infoWindow.setTitle(this.i18n.mapInfoWindow.identifyingTitle);

                this.map.infoWindow.setContent('<div class="loading"></div>');

                all(identifies).then(lang.hitch(this, 'identifyCallback', identifiedlayers, mapPoint), lang.hitch(this, 'identifyError'));

            } else {

                this.previewMode = true;

            }

        },

0 Kudos
5 Replies
thejuskambi
Occasional Contributor III

Could you also share the signature of the "identifyCallback". Does it has 3 parameters?

the syntax for the dojo/promise/all seems wrong. it should be something like

all(identifies).then( function(results){

     //here your code

});

but you seem to have replaced it with lang.hitch. but it does not have a error callback. may be thats what's wrong.

break inside the identifyCallback function and check the arguments parameter and check what values are returned.

0 Kudos
tylerjones1
New Contributor

identifyCallback: function (identifiedlayers, mapPoint, responseArray)

check which parameter? IdentifiedLayers has a value, mapPoint has value, but responseArray is empty

0 Kudos
thejuskambi
Occasional Contributor III

Sorry my bad, I wanted you to look at the arguments variable in the cosole.

0 Kudos
thejuskambi
Occasional Contributor III

quick question, the layer.identifyTask, are you adding this property to a esri Layer object, or it is your own object?

0 Kudos
tylerjones1
New Contributor

I am adding esri/Tasks/IdentityTask.

Request:

GET https://gis.aoscloud.net/gissandbox/rest/services/AOS/AOS_Internal_MapAnalytix/FeatureServer/identif... HTTP/1.1

Host: gis.aoscloud.net

Connection: keep-alive

Pragma: no-cache

Cache-Control: no-cache

Origin: https://localhost:44300

User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36

Content-Type: application/x-www-form-urlencoded

Accept: */*

Referer: https://localhost:44300/viewer/index.html

Accept-Encoding: gzip, deflate, sdch

Accept-Language: en-US,en;q=0.8,pt;q=0.6,es;q=0.4,de;q=0.2

Response:

{"currentVersion":10.31,"serviceDescription":"This is the feature layer","hasVersionedData":true,"supportsDisconnectedEditing":false,"syncEnabled":false,"supportedQueryFormats":"JSON, AMF","maxRecordCount":10000,"capabilities":"Create,Query,Update,Delete,Uploads,Editing","description":"","copyrightText":"","spatialReference":{"wkid":4326,"latestWkid":4326},"initialExtent":{"xmin":-119.35600738380732,"ymin":30.640244176615354,"xmax":-44.498164140386635,"ymax":56.90949368098167,"spatialReference":{"wkid":4326,"latestWkid":4326}},"fullExtent":{"xmin":-149.89270613499997,"ymin":-42.98254992799997,"xmax":147.0958894260001,"ymax":61.18943694300003,"spatialReference":{"wkid":4326,"latestWkid":4326}},"allowGeometryUpdates":true,"units":"esriDecimalDegrees","documentInfo":{"Title":"","Author":"","Comments":"","Subject":"","Category":"","Keywords":""},"layers":[{"id":0,"name":"2013 Total Sales"},{"id":1,"name":"2014 Total Sales"},{"id":2,"name":"AOS Offices"},{"id":3,"name":"Customers"},{"id":4,"name":"Competition"},{"id":5,"name":"Prospects"},{"id":6,"name":"Dormant Customers"},{"id":7,"name":"Unknown"},{"id":8,"name":"Zipcodes"}],"tables":[],"enableZDefaults":false}

0 Kudos