Select to view content in your preferred language

Query result graphics being returned backwards?

802
2
10-21-2010 08:49 AM
ReneRubalcava
Esri Frequent Contributor
I am having an odd problem this morning with graphics. I have a query that I use to query a layer, then populate the results to a GraphicsLayer.
Problem is, the graphics seem to be coming back in mirrored form from the actual data.

I have attached an image. The green shaded area is the service and the dark shaded area is the same polygon after it has been queried and displayed. Weird huh?

Unfortunately the service is not available to the public, but here is the REST data for it.
{
  "id" : 1, 
  "name" : "Landbase.SDE.LA_Parcels", 
  "type" : "Feature Layer", 
  "description" : "", 
  "definitionExpression" : "", 
  "geometryType" : "esriGeometryPolygon", 
  "copyrightText" : "", 
  "parentLayer" : null, 
  "subLayers" : [], 
  "minScale" : 10000, 
  "maxScale" : 0, 
  "defaultVisibility" : true, 
  "extent" : {
    "xmin" : -13241845.3287006, 
    "ymin" : 3867765.81297817, 
    "xmax" : -13096080.9165718, 
    "ymax" : 4139925.57253608, 
    "spatialReference" : {
      "wkid" : 102113
    }
  }, 


Here is the query.
public function findParcelFeatures(ains:Array):AsyncToken {
 var query:Query = new Query();
 query.outFields = ['*'];
 query.returnGeometry = true;
 query.where = queryStringFromArray(ains, "AIN");
 trace(query.where);
 return parcelFeaturesTask.execute(query);
 
 function queryStringFromArray(items:Array, fieldName:String):String {
  var where:String = fieldName;
  for each (var item:String in items) {
   if (item != "")
    where += " = " + item + " OR " + fieldName;
  }
  var fieldL:int = fieldName.length;
  var trim:int = (where.length - fieldL) - 4;
  return where.substr(0, trim);
 }
}


private function onParcelFeaturesLoaded_handler(fSet:FeatureSet):void {
 trace("got parcel features results", fSet.features.length);
 parcelLayer.clear();
 //parcelLayer.graphicProvider = fSet.features;
 for each (var g:Graphic in fSet.features) {
  parcelLayer.add(g);
 }
 map.extent = GraphicUtil.getGraphicsExtent(fSet.features);
}


I deleted the service, created a new MXD, created a new MSD and rebuilt the service, but the results are the same? Any clues as to what can be causing this?

Thanks.
Tags (2)
0 Kudos
2 Replies
ReneRubalcava
Esri Frequent Contributor
Ok, this was a weird problem. If I add the GraphicsLayer to the map right after initializing it at the same time as I dynamically add my service layers, the graphics are backwards.

So services is an array map service layers
for each (var layer:Layer in services) {
 map.addLayer(layer);
}
map.addLayer(parcelLayer);


But if I wait until the after I do the first query and add it, it works ok.

I just add this "if" statement in my Query Result handler
if (!map.getLayer(parcelLayer.id)) {
 map.addLayer(parcelLayer);
}


I don't know if it has to do with adding the GraphicsLayer before the map has been added to the stage or what exactly, but I'm going to enjoy the solution I found.
0 Kudos
philippschnetzer
Frequent Contributor
try removing the negatives from your min and max x extents or switching the min with the max or both...
0 Kudos