rprevost

Spatial Query Not Executing

Discussion created by rprevost on Jun 14, 2012
Latest reply on Jul 26, 2012 by jkindave
Hello Everyone,

I am trying to execute a spatial query to show all of the features within a county.  I am filtering this spatial query by date range (just for testing purposes), however, whenever I try to assign a geometry to the spatial query, the query will not execute.  I get no error, it just hangs and never finishes the process.  If I do not assign a geometry in the spatial query, it executes and displays all points in the featureLayer.

I modeled my code after code on the ESRI site (in particular, the spatial query buffer example), but even the esri code had the same problem when I copied it from their site and didnt change anything.

Here is the code I am using to call the spatial query.  This code is executed on the success of the query to find the county that the user selected.

dojo.connect(geometryQueryTask, "onComplete", function (fset) {
                var firstGraphic = fset.features[0];

                var query = new esri.tasks.Query();
                query.returnGeometry = true;
                query.outFields = ["*"];
                query.geometry = firstGraphic.geometry;
                query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_CONTAINS;
                query.outSpatialReference = { "wkid": 102100 };

                //where UTC date between date range
                var queryWhere = "UTCDate >= " + "'2011-01-27 08:12:30.000'" + " and UTCDate <= " + "'2011-01-28 12:12:30.000'";
                query.where = queryWhere;

                routeQueryTask.execute(query);

            });

and here is the code for the second query for the feature layer that never gets executed when I set a geometry in the above code:

            dojo.connect(routeQueryTask, "onComplete", function (fset) {
                //create symbol for selected features
                var symbol = new esri.symbol.SimpleMarkerSymbol();
                symbol.style = esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE;
                symbol.setSize(8);
                symbol.setColor(new dojo.Color([255, 255, 0, 0.5]));

                var resultFeatures = fset.features;
                for (var i = 0, il = resultFeatures.length; i < il; i++) {
                    var graphic = resultFeatures[i];
                    graphic.setSymbol(symbol);
                    map.graphics.add(graphic);
                }
            });

if anyone has any suggestions or has had this problem  before, any help would be much appreciated.

Thanks,

Ryan

Outcomes