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
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.
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.
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.