Select to view content in your preferred language

Reprojecting results from find task

655
4
Jump to solution
08-14-2012 03:38 PM
JimWharton
New Contributor III
I'm returning a bunch of objects from a find task that I'm performing, and my results are ending up in South Africa, not Florida where they should be.

My map is using a spatial reference of 102100. My results are coming back with a WKID of 2236.

I have tried specifying

findParams = new esri.tasks.FindParameters(); findParams.outSR = '102100';


I've also tried specifying that WKID as an integer (no quotes). I've tried specifying a new spatial reference like this:

var sr = new esri.SpatialReference(102100); findParams = new esri.tasks.FindParameters(); findParams.outSR = sr;


No matter what, my results come back with a WKID of 2236... and naturally, those plot quite far away from where they should.

How do I get these points back where they belong?
0 Kudos
1 Solution

Accepted Solutions
JohnGravois
Frequent Contributor
Heres a fiddle which shows how to reproject returned geometries successfully.

http://jsfiddle.net/jagravois/nQGdA/

I double checked my previous post and noticed that i had accidently copied the incorrect property name "outSR" in my code rather than "outSpatialReference".  I corrected the previous post to avoid further confusion.

View solution in original post

0 Kudos
4 Replies
JohnGravois
Frequent Contributor
The outSpatialReference property of findParameters is expecting a spatial reference object.  The code below demonstrates the proper syntax.

ie:
var sr = new esri.SpatialReference({wkid:102100});
//findParams.outSR = sr (incorrect)
findParams.outSpatialReference = sr


findParameters in the API reference
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/findparameters.htm

spatialReference
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/spatialreference.htm
0 Kudos
JimWharton
New Contributor III
Thanks. Unfortunately, the objects are still coming back with a spatialReference of 2236.

I loop through the results like this:

dojo.forEach(results, function(result) {
      var graphic = result.feature;
      // x = graphic;
      // dataForGrid.push([result.layerName, result.foundFieldName, result.value]);
      switch (graphic.geometry.type) {
      case "point":
        graphic.setSymbol(markerSymbol);
        break;
      case "polyline":
        graphic.setSymbol(lineSymbol);
        break;
      case "polygon":
        graphic.setSymbol(polygonSymbol);
        break;
      }
      console.log(graphic);
      map.graphics.add(graphic);

    });


When I log out the graphic object (that I set to the feature attribute of the result) the spatial reference doesn't change.
0 Kudos
JohnGravois
Frequent Contributor
Heres a fiddle which shows how to reproject returned geometries successfully.

http://jsfiddle.net/jagravois/nQGdA/

I double checked my previous post and noticed that i had accidently copied the incorrect property name "outSR" in my code rather than "outSpatialReference".  I corrected the previous post to avoid further confusion.
0 Kudos
JimWharton
New Contributor III
I'm going to need to go back and try that! Thanks.

I rewrote the whole app based on WKID 2236 and used dynamic layers on top of that. That got me the result I needed, but I still have the old code in GIT so I can't wait to try your soluction.

Thanks for getting back to me on this!
0 Kudos