This content has been marked as final. Show 3 replies
ok I find out how to convert the SpatialReference, but can someone of you tell me why the Point which is given as a Parameter in the ZoomToResolution-Function is not the center of the map?
Here is the new code...
SpatialReference sp = new SpatialReference(); sp.WKID = 4326; MapPoint mpZoomToGPSPosition = new MapPoint(); mpZoomToGPSPosition.SpatialReference = sp; mpZoomToGPSPosition.Y = epl.Latitude; mpZoomToGPSPosition.X = epl.Longitude; MyMap.ZoomToResolution(MyMap.Resolution / 5, new WebMercator().FromGeographic(mpZoomToGPSPosition) as MapPoint);
and here is the result in a screenshot....[ATTACH=CONFIG]12411[/ATTACH]
The blue marker shows the Position of the Mappoint "mpZoomToGPSPosition".
my position.png 393.9 K
The point paramter is not the point it centers on - It's the point it zooms 'around'. Ie if you give it the upper left corner, and say "New York" was up in that corner, New York would stay in this corner, and everything else expand out around it.
If you want to zoom and center to a point, you should create an envelope around the point and zoom to that (you can't zoom to a point, since it is infinitely small). Ie.
map.ZoomTo(new Envelope(p.X-10,p.Y-10, p.X+10,p.Y+10));
Thank you SharpGIS! That was the answer on my question!