This is a migrated thread and some comments may be shown as answers.

Assistance with Location Object!

4 Answers 108 Views
Map
This is a migrated thread and some comments may be shown as answers.
James Craig
Top achievements
Rank 1
James Craig asked on 13 Apr 2010, 10:26 AM
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



4 Answers, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 13 Apr 2010, 11:13 AM
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.
0
James Craig
Top achievements
Rank 1
answered on 13 Apr 2010, 11:28 AM
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
0
Vien Nguyen
Top achievements
Rank 1
answered on 25 Mar 2011, 08:58 PM
Is there a formula that I can do this programmatically? Thanks
0
Andrey
Telerik team
answered on 30 Mar 2011, 12:17 PM
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
Tags
Map
Asked by
James Craig
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
James Craig
Top achievements
Rank 1
Vien Nguyen
Top achievements
Rank 1
Andrey
Telerik team
Share this question
or