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.

I am currently writing the "Zoom to Layer" function for my application. However, the spatial references between my imported layer and my base map are different.

Is there a way around this? Can I somehow project all of my shapes/graphics so that they are in the base map's spatial reference?

Is my only option to remove all layers, change spatial reference, and add layers back in?

It seems like ArcEngine's spatial reference had less restriction and was easier to use. Any insights?

Thanks for all your help, Kev

share|improve this question
add comment

3 Answers 3

I had this same issue. If you look at this thread you'll see that an ArcGISTiledMapServiceLayer does not reproject into the map's spatial reference, because each tile is specifically rendered in one certain spatial reference. Instead you should use an ArcGISDynamicMapServiceLayer with the same URL. This will remove the nice tile-by-tile loading functionality, but it will automatically reproject the layer to your map's spatial reference.

I use a combined approach. I first try to load a tiled layer, and when the layer's Initialized event fires, I make sure that the spatial reference is the same as the map's. If it's not the same, then I remove the tiled layer and replace it with a dynamic layer.

share|improve this answer
add comment

I have used the OutSpatialReference property on the Query class when retrieving features from a map service using a QueryTask to project the features into the correct spatial reference before adding them to a graphic layer.

var task = new QueryTask(queryUrl);

var query = new Query
{
    ReturnGeometry = true,
    ObjectIDs = oids,
    OutSpatialReference = spatialReference // spatial reference of basemap
};

var tcs = new TaskCompletionSource<FeatureSet>();
task.ExecuteCompleted += (s, e) => tcs.TrySetResult(e.FeatureSet);
task.Failed += (s, e) => tcs.TrySetException(e.Error);
task.ExecuteAsync(query);
share|improve this answer
add comment

Can't you project the layer's extent to map's spatial reference via GeometryService.Project()?

It can be done locally in conjuction with LocalGeometryService.

share|improve this answer
add comment

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.