Select to view content in your preferred language

Map zooming to proper level

511
1
05-21-2012 04:34 AM
JustinDyer
Emerging Contributor
I am doing a query against an ESRI service and am getting back a feature set with a number of features.

I want to zoom on my map so that all of these features. To do this, I used the following code:
map.ZoomTo(new Envelope(featureSet.Features.Min(x => x.Geometry.Extent.XMin), featureSet.Features.Min(x => x.Geometry.Extent.YMin),
                        featureSet.Features.Max(x => x.Geometry.Extent.XMax), featureSet.Features.Max(x => x.Geometry.Extent.YMax)));


In some cases some of the map that should be shown whenever a zoom happens is not on the screen. I usually have to roll my mouse wheel back a level to see the rest of the map that should be shown. I am guessing that because my map didn't have a scale level to that particular zoom, it rounded down and zoomed in a little farther than it should have. Is there some way I can do a check of some sort to insure that all my features are shown on the map when I zoom?
0 Kudos
1 Reply
JenniferNery
Esri Regular Contributor
I could not reproduce this issue. I wonder if maybe Map.SpatialReference has not yet been set when you call Map.ZoomTo()?
0 Kudos