Longitude, latitude problem

I have been using the virtual earth control and have a couple of questions. I would like the map to initially focus over Turkey in Europe. I would then like to place a push pin over the city of Instanbul.

My question is how do I find the longitude and latitude of this country and city so I can use the map control? Or is there another way of doing it without knowing the longitude and latitude?

Thanks

Danny

[943 byte] By [dannyg_uk] at [2007-12-24]
# 1

So, Istanbul, he?

its lat:41.01437

lon:28.96352

JeffK at 2007-10-8 > top of Msdn Tech,Windows Live Developer Forums,Virtual Earth: Map Control Development...
# 2

Thanks for the reply. How did you get that? And can that be used to set the virtual earth map control?

Thanks

Danny

dannyg_uk at 2007-10-8 > top of Msdn Tech,Windows Live Developer Forums,Virtual Earth: Map Control Development...
# 3

I used my Mappoint 2004 for that

but you can also use the virtualearth control for it.

use following code for it

var map = null;
var pin=null;
function Page_Load()
{
map = new VEMap('divMap');
map.LoadMap(new VELatLong( 51,7), 18 ,'r' ,false);

map.AttachEvent("onclick",ShowCoords);

}


function ShowCoords(e)
{
alert(e.view.LatLong.Latitude+ " " + e.view.LatLong.Longitude);
}

the Page_Load function loads the map, and attaches the onclick event of the map to the ShowCoords function.

JeffK at 2007-10-8 > top of Msdn Tech,Windows Live Developer Forums,Virtual Earth: Map Control Development...
# 4

Lets say I just have the "name" of a city, like Istanbul, what is the easiest way to display this city with the map control.

Thanks

Danny

dannyg_uk at 2007-10-8 > top of Msdn Tech,Windows Live Developer Forums,Virtual Earth: Map Control Development...
# 5
I'm not sure if doing a Find would work for you or not.

If this is a situation where you need to get the lat/long before hand and hard code it you could do it the way I have been (I'm sure there is a better way but now that I've found something that works I haven't looked).

function GetMap()
{
map = new VEMap('myMap2');
map.LoadMap(null, null ,'a' , false);
map.GetRoute("Istanbul, Istanbul, Turkey", "Istanbul, Istanbul, Turkey",null,null, onGotRoute);
}

function onGotRoute(route)
{
var endLoc = route.EndLocation.LatLong;
alert(endLoc.Latitude);
alert(endLoc.Longitude);
}

Like I said I know this isn't the best but it will work.

Ruprect8696 at 2007-10-8 > top of Msdn Tech,Windows Live Developer Forums,Virtual Earth: Map Control Development...
# 6

There is an easier way,

the map object got a method called 'Find'

map.Find("","Istanbul,1,myCallback);

the callbackfunction gets an array of VEFindResults or an array of VESearchResults, which one depends on the search parameters.

JeffK at 2007-10-8 > top of Msdn Tech,Windows Live Developer Forums,Virtual Earth: Map Control Development...

Windows Live Developer Forums

Site Classified