Hi
I'm new on ArcGIS ESRI, so sorry for my question :
I try to zoom on a MapPoint but nothing run. I've try the "CenterAndZoom" method and the ZoomTo(new Envelope(...)).
This is my code :
private void _mapLoad(object sender, RoutedEventArgs e)
{
GraphicsLayer gLayer = MyMap.Layers["G_LAYER"] as GraphicsLayer;
if (gLayer == null)
{
gLayer = new GraphicsLayer(){ ID = "gLayer" };
MyMap.Layers.Add(gLayer);
Graphic marker = new Graphic();
marker.Symbol = new SimpleMarkerSymbol();
gLayer.Graphics.Add(marker);
}
MapPoint location = new MapPoint(46.780764, 4.853947000000062, MyMap.SpatialReference);
gLayer.Graphics[0].Geometry = ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(location);
Envelope envFullExtent = gLayer.FullExtent;
MyMap.ZoomTo(envFullExtent);
MyMap.PanTo(location);
//MyMap.ZoomTo(new Envelope(location.X - 100, location.Y - 100, location.X + 100, location.Y + 100));
//_centerAndZoom(MyMap, location, MyMap.Resolution);
}
//private void _centerAndZoom(Map map, MapPoint mapPoint, double resolution)
//{
// double ratio = 1.0;
// if (map.Resolution != 0.0)
// {
// ratio = resolution / map.Resolution;
// }
// if (ratio == 1.0)
// {
// map.PanTo(mapPoint);
// }
// else
// {
// MapPoint mapCenter = map.Extent.GetCenter();
// double X = (mapPoint.X - ratio * mapCenter.X) / (1 - ratio);
// double Y = (mapPoint.Y - ratio * mapCenter.Y) / (1 - ratio);
// map.ZoomToResolution(resolution, new MapPoint(X, Y));
// }
//}With the "CenterAndZoom" method, I have a "NullReferenceException" on the "map.Extent.GetCenter();" (l. 43) and for the "MyMap.ZoomTo(new Envelope(location.X - 100, location.Y - 100, location.X + 100, location.Y + 100));", I have a blank page with my point in the left up corner. For the "ZoomTo" with "PanTo", nothing.
Please, can you bring me your help ?
Thanks to you