AnsweredAssumed Answered

Get x,y from identifed feature(s)

Question asked by gopre400 on Jan 10, 2014
Latest reply on Jan 10, 2014 by gopre400
Hi, I would like to get the x,y from identified features when user clicks on map. I would also like to get the count of features found. Does anyone have an exmaple or resource to point me to? Thank you!

Here is code to identify features when user clicks...

function mapReady(map) {
            getLocation();
            dojo.connect(map, "onClick", executeIdentifyTask);
            identifyTask = new esri.tasks.IdentifyTask("http://gisappserv3/ArcGIS/rest/services/Engineering/MaintenancePoints/MapServer");
            identifyParams = new esri.tasks.IdentifyParameters();
            identifyParams.tolerance = 5;
            identifyParams.returnGeometry = true;
            identifyParams.layerIds = [2, 15];
            identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE;
            identifyParams.width = map.width;
            identifyParams.height = map.height;
        }

function executeIdentifyTask(evt) {
            identifyParams.geometry = evt.mapPoint;
            alert(identifyParams.geometry('x'));        
            identifyParams.mapExtent = myMap.extent;              
            var deferred = identifyTask.execute(identifyParams);
            deferred.addCallback(function (response) {
                return dojo.map(response, function (result) {
                    var feature = result.feature;
                    feature.attributes.layerName = result.layerName;
                    console.log(feature.attributes.Location);
                    if (result.layerName === 'Maintenance Districts') {
                        $('input:radio[name="radioMaintDist"]').filter('[value="' + feature.attributes['District'] + '"]').next().click();
                    }
                    else {
                        $('#popStructureType').val(feature.attributes['Display Name']);
                    }
                    $('#popSWUStructure').popup('open');
                    var template = new esri.InfoTemplate("", "Facility ID: ${Manhole I.D.} <br/>");
                    feature.setInfoTemplate(template);
                    return feature;
                });
            });             
        }

Outcomes