In my silverlight apps i am trying to have the map zoom to the results of queries or GP tasks (graphics layers) with the following C# code:
MyMap.ZoomTo(graphicsLayer.FullExtent)
When i do so, the furthest outlying feature is right on the edge of the map. So I want to zoom to something just greater than the full extent so there is a little space between my furthest out feature and the edge of the map.
So I came up with something like this:
Envelope myExtent = new Envelope();
myExtent.XMax = ((graphicsLayer.FullExtent.XMax) + 0.02);
myExtent.XMin = ((graphicsLayer.FullExtent.XMin) - 0.02);
myExtent.YMax = ((graphicsLayer.FullExtent.YMax) + 0.02);
myExtent.YMin = ((graphicsLayer.FullExtent.YMin) - 0.02);
//MyMap.ZoomTo(graphicsLayer.FullExtent)
MyMap.ZoomTo(myExtent);
But this only works for zooming in a narrow range of scales. If scales vary greatly this kind of approach does not work well.
Have you seen any examples of a better way to do this??