I'm having a problem zooming in on a point when my page first loads. I tried waiting for the intialize event of both my layers before calling ZoomTo() but nothing happens. After everything has loaded I can call ZoomTo from a button click and it works fine.private void ZoomTo(double lat, double lng, int level)
{
var newResolution = GetResolution(level);
double halfWidth = newResolution * MyMap.ActualWidth / 2;
double halfHeight = newResolution * MyMap.ActualHeight / 2;
var point = new MapPoint(lat, lng, MyMap.SpatialReference);
Envelope newExtent = new Envelope(point.X - halfWidth, point.Y - halfHeight, point.X + halfWidth, point.Y + halfHeight);
MyMap.ZoomTo(newExtent);
}
<esri:Map WrapAround="True" x:Name="MyMap" Grid.Row="1" Grid.ColumnSpan="2">
<esri:ArcGISTiledMapServiceLayer Initialized="MyMapLayer_Initialized"
Url="{StaticResource MapUrl}"/>
<esri:GraphicsLayer Initialized="MyMapLayer_Initialized">
</esri:GraphicsLayer>
<i:Interaction.Behaviors>
<esri:MaintainExtentBehavior />
</i:Interaction.Behaviors>
</esri:Map>