Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Is there a way to get to the query condition, which is executed under the querytask ?

I have an example, which is actually a copy of this ArcGIS example http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/fl_popup.html, but like my other examples, I can't get it working with my examples.

There is something like this:

    dojo.connect(map,"onClick",function(evt){
      var query = new esri.tasks.Query();
      query.geometry = pointToExtent(map,evt.mapPoint,10);
      var deferred = featureLayer.selectFeatures(query,esri.layers.FeatureLayer.SELECTION_NEW);
      map.infoWindow.setFeatures([deferred]);
      map.infoWindow.show(evt.mapPoint);
    });

    var template = new esri.InfoTemplate();
    template.setContent(getTextContent);

    var featureLayer = new esri.layers.FeatureLayer("http://servicesbeta.esri.com/arcgis/rest/services/SanFrancisco/SFStreetTreesRendered/MapServer/0",{
      mode: esri.layers.FeatureLayer.MODE_SELECTION,
      outFields: ["*"],
      infoTemplate:template
    });

    map.addLayer(featureLayer);

 function pointToExtent(map, point, toleranceInPixel) {
   var pixelWidth = map.extent.getWidth() / map.width;
   var toleraceInMapCoords = toleranceInPixel * pixelWidth;
   return new esri.geometry.Extent( point.x - toleraceInMapCoords,
                point.y - toleraceInMapCoords,
                point.x + toleraceInMapCoords,
                point.y + toleraceInMapCoords,
                map.spatialReference );                           
  }

If I'm reading the code correctly, then when I click the map, it gets the coordinates (query.geometry) of the clicked map part (in my case is it a region), which should get highlighted by a line and then a popup should show with whatever info I got from the query. But all I get is the default message "No information available".

When I tried to change the where condition for the query by myself like this:

query.where = "Chripka.CISOKRES = 503 AND Chripka.STARTAGE = 6 AND Chripka.RANGEAGE = 8 AND Chripka.PERIODSTART >= date '10/13/2006' AND Chripka.PERIODSTART < date '10/20/2006'";

it did the job, because the query returned only one record, but that's the catch, I never know which region is selected, so this condition (Chripka.CISOKRES = 503) is unknown for me. So I tried this condition

query.where = "Chripka.STARTAGE = 6 AND Chripka.RANGEAGE = 8 AND Chripka.PERIODSTART >= date '10/13/2006' AND Chripka.PERIODSTART < date '10/20/2006'";

instead, but the query returns more than 30 records, nothing gets highlighted and the popup ends with "No information available".

So I thought, that maybe I could look into the query condition which is used for the data retrieval. Is it possible ?

One thing to mention is, that my web service is running on a very slow server with no possibility to get a better one. I have to wait for 4 seconds, till I get the result, when a timeSlider changes its TimeExtent. I'm using IE9 and there's no way that I can change it for another web browser, because our customer is using IE9.

Thank you g

P.S.Actually, the same question goes to TimeSlider. Is there a way to see, what query is executed behind the TimeSlider when its TimeExtent changes ?

share|improve this question

1 Answer 1

If you want to look at the contents of the query object, three options:

  1. In IE9, hit f12 key, click start debugging, set a breakpoint within the onclick connect -- check it out in locals or add a watch
  2. Insert a statement console.log(JSON.stringify(query)); to print to console of debugger
  3. Insert alert(JSON.stringify(query));

It's unclear to me why you're not getting results, but follow best practices -- I have to remind myself this all the time. Get the exact example to work. Make sure file references are all okay. Check out the console for errors. Then, make small changes and test so you'll know exactly where an error is introduced. Cheers!

share|improve this answer
    
Hi, thanks for your answer, but that's not what I wanted. When I used JSON.stringify(query), I got this: "{"spatialRelationship":"esriSpatialRelIntersects","geometry":{"type":"extent","‌​xmin":2252472.3041251404,"ymin":6301118.863947042,"xmax":2264702.2286507683,"ymax‌​":6313348.78847267,"spatialReference":{"wkid":102100}}}". Actually I was expecting something like this: 'col1 = 5 and col3 = 8 and colDate > '09/29/2006'' –  ghostC Apr 19 '13 at 6:19
    
When you add the where clause to the query, it should print that along with the other attributes... –  awesomo Apr 19 '13 at 16:09
    
That's the point, I don't add any where condition manually, but I think, that the where condition is constructed by selecting part of a visible layer. Maybe I'm wrong, but I've thought, that this line is behind the where condition construction: query.geometry = pointToExtent(map,evt.mapPoint,10); –  ghostC Apr 22 '13 at 6:23
    
May not be understanding... but when you select part of the visible layer, say an extent (or a user drawn polygon), it doesn't go into the where clause that you send to server. It is the query.geometry part. It looks like your first comment "geometry": {"type": extent....}. The where clause is separate, it is additional, e.g. query.where = 'col1 = 5 and col3 = 8 and colDate > "09/29/2006"'; –  awesomo Apr 22 '13 at 19:55
    
Thank you for the explanation. –  ghostC Apr 23 '13 at 4:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.