3

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

2

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.

0

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);
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.