Assistance with Location Object!

5 posts, 0 answers
  1. James Craig
    James Craig avatar
    30 posts
    Member since:
    Mar 2010

    Posted 13 Apr 2010 Link to this post

    Good Day All,

    I've just got started with RadMap and require a little assistance.  When I put the following co-ordinates into Google maps, I'm presented with a view directly over the center of Manchester, UK:

    53°29'N 02°12'W

    When I try to show the same location in RadMap (using code below) I end up around 50 miles to the South and 10 miles to the East of the intended target.

    map.Provider = new BingMapProvider(MapMode.Aerial, true, "ZZZZZZZZZZZ");
    map.Center = new Location(53.29, -2.12);
    map.ZoomLevel = 12;

    Please could someone help address this obvious deficit in my knowledge of geography :) ?

    Many thanks,
    James



  2. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 13 Apr 2010 Link to this post

    Hello James,

    The latitude / longitude coordinates of the Location object should be specified as decimal degrees (versus the degree, minutes, seconds notation) i.e. the representation of 53°29'N 02°12'W in decimal degrees is 53.4833333333333, -2.2 and you need to set the Center property like this (you can use free online converters as this one for the actual conversion):

    RadMap1.Center = new Location(53.483333, -2.2);

    Hope this helps.


    Greetings,
    Freddie
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft banner
  4. James Craig
    James Craig avatar
    30 posts
    Member since:
    Mar 2010

    Posted 13 Apr 2010 Link to this post

    Hello Freddie,
    That's precisely what I needed to know.  Clearly I should have concentrated harder in Geography class!  Thanks for taking the trouble to reply.

    Best regards,
    James
  5. Vien Nguyen
    Vien Nguyen avatar
    8 posts
    Member since:
    Jul 2007

    Posted 25 Mar 2011 Link to this post

    Is there a formula that I can do this programmatically? Thanks
  6. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 30 Mar 2011 Link to this post

    Hello Vien Nguyen,

    One degree contains 60 minutes. One minute contains 60 seconds. So, you can calculate the coordinate in fractional degrees from the coordinate in degrees, minutes and seconds like to the following way:
    // 53°29'N
    double latitude = this.GetFractionalDegrees(false, 53, 29, 0);
    // 02°12'W
    double longitude = this.GetFractionalDegrees(true, 2, 12, 0);
    Location location = new Location(latitude, longitude);

    private
    double GetFractionalDegrees(bool southOrWest, int degrees, int minutes, int seconds)
    {
        double fractionalDegrees = (double)degrees;
        fractionalDegrees += ((double)minutes) / 60d;
        fractionalDegrees += ((double)seconds) / 3600d;

        
    if (southOrWest)
        {
            fractionalDegrees = -fractionalDegrees;
        }

        
    return fractionalDegrees;
    }

    Greetings,
    Andrey Murzov
    the Telerik team
Back to Top
DevCraft banner