AnsweredAssumed Answered

selectFeatures() not working

Question asked by mshah12 on Jun 14, 2018

I have a layer on top of my basemap that shows the jobs that I have created in certain parts of the world. I am trying to use the selectFeatures() method to be able to get information about a particular job once I click on it on the map. I am using the following code, but I get back an empty array when the features portion is printed to the console. And sometimes the function does not even get to the point where it will print the query, or "features: [ ]" to the console if I change something in another function. I believe the rest of the properties in query are set to the right values. Can anyone see what I might be doing wrong?

 

Thank you for any help. 

 

_selectJobByMapClick: function(clickGeom){
            console.log("cx selectJobByMapClick() start, clickGeom: ", clickGeom);
            var newPoint = webMercatorUtils.webMercatorToGeographic(new Point(clickGeom.x, clickGeom.y,             clickGeom.spatialReference.wkid));
            console.log("newPoint: ", newPoint);
            var query = new Query();
            query.outFields = ["*"];
            query.returnGeometry = true;
            query.outSpatialReference = newPoint.spatialReference.wkid;
            query.geometry = newPoint;
            query.where = "JTX.JTX_JOBS_AOI.JOB_ID = -1";
            console.log("after query.where and before the lang.hitch()");
            
            this.jobLayer.clearSelection();
            console.log("FeatureLayer.SELECTION_NEW: ", FeatureLayer.SELECTION_NEW);
             this.jobLayer.selectFeatures(query, FeatureLayer.SELECTION_NEW, lang.hitch(this, function(features){
                console.log("query: ", query);
                console.log("features: ", features);
            }));
     },

Outcomes