IdentifyTask Where Map And Services SpatialReference Are Different?

388
3
06-04-2010 01:59 PM
RyanCoodey
Occasional Contributor III
So I have a map with multiple services each with different SpatialReferences... the Map takes on one of these when initializing.  I want to run an IdentifyTask on a service layer with a different SpatialReference than the map...

Setting the IdentifyParameters (just like in the samples):
     identifyParameters = new IdentifyParameters()
     {
          Geometry = e.MapPoint,
          MapExtent = Map.Extent,
          Width = (int)Map.ActualWidth,
          Height = (int)Map.ActualHeight,
          LayerOption = LayerOption.visible,
     };


So Geometry and MapExtent should always be in the same SpatialReference (as the Map), but the service is in another...  Setting identifyParameters.SpatialReference to that of the layer doesn't work, because it is just defining it incorrectly for Geometry and MapExtent.

What should I do?  Do I have to use a GeometryService and project something?  If so, that is done asynchronously so I guess I would have to wait and then launch the IdentifyTask from there...  This seems a bit hokey, any better ideas?

Thanks a lot for any ideas!!!
0 Kudos
3 Replies
ChrisBradberry
Occasional Contributor
Ryan,

I would try to get the services into a common projection.  That will help the map to load faster, and run faster. 

If you can't do that, you could just project the map click point coordinates.  That is fairly quick, and then run the identify with the projected coordinates.

Chris
0 Kudos
dotMorten_esri
Esri Notable Contributor
It's not a problem with multiple spatial references. ArcGIS Server can reproject on the fly. You will want to set the spatialreference parameter on the IdentifyParameters and Sref on the Geometry to be that of the map, and not the service's default spatial reference.
See the description of the property in the library reference: http://help.arcgis.com/en/webapi/silverlight/apiref/topic1854.html
0 Kudos
RyanCoodey
Occasional Contributor III
Great! Thanks Morten!  I missunderstood the lib refrence when I read it earlier... was thinking if i didn't set the sr it was using the same as the maps, but i set it to that of the map and lo and behold, it works.  Bradberry, thanks for the other good tips.

This makes my life much easier, thanks guys!
0 Kudos