germana


Hi!! im new in Virtual Earth.... and i have a question...

How can i get the latitud and longitud, of a selected area, width the middle mouse button, to make a search in a database with that longitud and latitud

Thanks!!



Re: Question ???????

Duncan Garratt


This code might be of help

function GetMap()
{
map = new VEMap('myMap');
map.LoadMap();

map.AttachEvent("onclick",MouseHandler);
map.AttachEvent("ondoubleclick",MouseHandler);
map.AttachEvent("onmousedown",MouseHandler);
map.AttachEvent("onmouseup",MouseHandler);
map.AttachEvent("onmousewheel",MouseHandler);
}

function MouseHandler(e)
{
if (e.eventName == "onclick")
{
if (e.leftMouseButton)

{
Do Something

}

else if (e.rightMouseButton)

{

Do Something

}
else if (e.leftMouseButton)

{

Do Something

}
}

}







Re: Question ???????

germana

Duncan Garratt wrote:

This code might be of help

function GetMap()
{
map = new VEMap('myMap');
map.LoadMap();

map.AttachEvent("onclick",MouseHandler);
map.AttachEvent("ondoubleclick",MouseHandler);
map.AttachEvent("onmousedown",MouseHandler);
map.AttachEvent("onmouseup",MouseHandler);
map.AttachEvent("onmousewheel",MouseHandler);
}

function MouseHandler(e)
{
if (e.eventName == "onclick")
{
if (e.leftMouseButton)

{
Do Something

}

else if (e.rightMouseButton)

{

Do Something

}
else if (e.leftMouseButton)

{

Do Something

}
}

}




ok.... with this, as i understand, i get the mouse events right but how can i get the longitud and latitud of the selected area..





Re: Question ???????

germana

Duncan Garratt wrote:

This code might be of help

function GetMap()
{
map = new VEMap('myMap');
map.LoadMap();

map.AttachEvent("onclick",MouseHandler);
map.AttachEvent("ondoubleclick",MouseHandler);
map.AttachEvent("onmousedown",MouseHandler);
map.AttachEvent("onmouseup",MouseHandler);
map.AttachEvent("onmousewheel",MouseHandler);
}

function MouseHandler(e)
{
if (e.eventName == "onclick")
{
if (e.leftMouseButton)

{
Do Something

}

else if (e.rightMouseButton)

{

Do Something

}
else if (e.leftMouseButton)

{

Do Something

}
}

}





Re: Question ???????

Duncan Garratt

This should do the job

var x = e.mapX;

var y = e.mapY;

var pixel = new VEPixel(x, y);

var latlong = map.PixelToLatLong(pixel);

var latitude = Math.round(10000*latlong.Latitude)/10000;

var longitude = Math.round(10000*latlong.Longitude)/10000;