+ Reply to Thread
Results 1 to 4 of 4

Thread: Zoom to a Point in the Map

  1. #1
    Darko Stanojevic
    Join Date
    Mar 2012
    Posts
    4
    Points
    0
    Answers Provided
    0


    0

    Default Zoom to a Point in the Map

    Hello,

    I have the problem, that I need to zoom to a specific Point (my own GPS Position) in the Map... but the SpatialReference of the
    Mappoint (with the GPS-Coordinates) seems to be different, than the SpatialReference from Bing Maps. Here is the relevant part of the 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, mpZoomToGPSPosition);


    The "ZoomToResolution"-Function works, but the WKID of the SpatialReference of "MyMap" (this is the whole map declared in the xaml-File) is "102100". Can someone help
    me please.
    Is it maybe possible to change the WKID of "MyMap".

    Thank you.

  2. #2
    Darko Stanojevic
    Join Date
    Mar 2012
    Posts
    4
    Points
    0
    Answers Provided
    0


    0

    Default Re: Zoom to a Point in the Map

    Hello,

    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...
    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....Click image for larger version

Name:	my position.png
Views:	100
Size:	393.9 KB
ID:	12411

    The blue marker shows the Position of the Mappoint "mpZoomToGPSPosition".

  3. #3
    Morten Nielsen

    Join Date
    Oct 2009
    Posts
    1,166
    Points
    44
    Answers Provided
    7


    1
    This post is marked as the answer

    Default Re: Zoom to a Point in the Map

    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));
    /Morten Nielsen
    ArcGIS Runtime SDK for .NET
    silverlight team blog - twitter - personal blog

  4. #4
    Darko Stanojevic
    Join Date
    Mar 2012
    Posts
    4
    Points
    0
    Answers Provided
    0


    0

    Default Re: Zoom to a Point in the Map

    Thank you SharpGIS! That was the answer on my question!

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts