Select to view content in your preferred language

Graphics don't display; spatial reference issue

970
4
09-26-2013 08:14 AM
KaitlynnDavis
Regular Contributor
I am having trouble adding my query results to my map as graphics. Firebug shows that my query is returning the correct features. The only thing that seems off is that they are being returned with the spatial reference of wkid 102711, whereas my map is in 102011. I don't understand why this is, since I have set the outSpatialReference property to be 102011 (my console.log proves this). Could this mismatch be the problem and if so what can I try to fix this?

var queryRecArea = new esri.tasks.RelationshipQuery();
queryRecArea.outFields = ["*"];
queryRecArea.returnGeometry = true;
console.log("spatial reference:", map.spatialReference);
queryRecArea.outSpatialReference = map.spatialReference; 
queryRecArea.relationshipId = 4;
queryRecArea.objectIds = [feature.attributes.OBJECTID];
queryRecArea.where = layerDefs;
documents.queryRelatedFeatures(queryRecArea, function(relatedRecords2) {
  console.log("relatedRecords2:", relatedRecords2);
  fset = relatedRecords2[fsetObjectIDArrayArea[0]];
  console.log("fset:", fset.features);
  for(var i=0, il = fset.features.length; i < il; i++){
  thirdGraphics = fset.features;
  var symbol4 = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0]), 3), new dojo.Color([125,125,125,0.35]));
  thirdGraphics.setSymbol(symbol4);
  map.graphics.add(thirdGraphics);
                }
});
0 Kudos
4 Replies
HaroldYang
Deactivated User
Hi, Kait,

Did you resolve your issue? I had same issue and found that it is related to the query using objectIds property.  Whenever a query is sent with objectIds set, the outSpatialReference paramter will be ignored and the geometries are sent back in the layer's original spatial reference.  I believe it is a bug in ESRI's API.

Harold
0 Kudos
KaitlynnDavis
Regular Contributor
Hi Harold,

I was advised by a tech support analyst to use the project method from the geometry service class (https://developers.arcgis.com/javascript/jsapi/geometryservice-amd.html#project). This sucessfully allowed me to reproject my graphics in the desired spatial reference value.  I was not aware that the objectIds query parameter was to blame for my issue though. It makes sense though; I've noticed this issue several times since and have just resorted to the projection tool when needed. Thanks for sharing
0 Kudos
HaroldYang
Deactivated User
Hi, Kait,

Thanks for the quick reply.  I will follow your suggestion to use the geometry service's project method. Though it adds some overhead in terms of performance, this might be the proper workaround about this issue.  Thanks very much.

Harold
0 Kudos
JoseSanchez
Frequent Contributor
Hi Kaitlynn

I am having the same problem! Do you mind posting the source code to explain how to use the project method from the geometry service class.

Thanks
0 Kudos