Select to view content in your preferred language

Query for polygon and adjacent polygons

1031
2
08-13-2010 09:43 AM
LucBelliveau
New Contributor
I am trying to implement the sample titled "Query for polygon and adjacent polygons" from the resource center, but there seems to be something not right...

The first query runs successfully, and returns a feature which I can add as a graphic to the map... when I try and pass the geometry of the retrieved feature, it simply stops... no error messages, nothing. 

If I comment out the "query.geometry = firstGraphic.geometry;" line, it executes the second query (with invalid results of course)...

Any ideas what could be happening?

            var csdTask = new esri.tasks.QueryTask("http://foo/MapServer/107");
            var csdTask2 = new esri.tasks.QueryTask("http://foo/MapServer/107");

              var query = new esri.tasks.Query();
              query.returnGeometry = true;
              query.outFields = ["NAME"];

              dojo.connect(map, 'onClick', function(evt) {
                map.graphics.clear();
                map.infoWindow.hide();
                query.geometry = evt.mapPoint;
                query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_INTERSECTS;
                csdTask.execute(query);
              });

              var firstGraphic = null;
              dojo.connect(csdTask, 'onComplete', function(graphics) {
                  firstGraphic = graphics.features[0];
                  var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new dojo.Color([100,100,100]), 3), new dojo.Color([255,0,0,0.20]));
                  firstGraphic.setSymbol(symbol);
                  map.graphics.add(firstGraphic);

                  query.geometry = firstGraphic.geometry;
                  query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_TOUCHES;
                  console.log('one');
                  csdTask2.execute(query);
                  console.log('two');

              });

             dojo.connect(csdTask2, "onComplete", function(fset) {
               console.log('TEST');
              });
0 Kudos
2 Replies
derekswingley1
Deactivated User
For your second query to run successfully, you'll probably need to configure a proxy. From the sample's page:
Notice that this sample references a proxy page in case the geometry of the first block group is so complex that the second query exceeds the maximum 2000 character limit that some browsers impose on GET requests. See Using the proxy page to learn more about this.
0 Kudos
LucBelliveau
New Contributor
Thanks... simple enough...

I guess I expected an error to be returned by the browser if that was the case...
0 Kudos