Two people doing their own thing.

Microsoft Certified Partner Soul Solutions
Sep 21

Written by: Soul Solutions
Thursday, 21 September 2006

johnWeeGo.jpgIf you have played with Virtual Earth you will have noticed that if you click on a pushpin it actually cancels the mouseover event and your popup ballon doen't appear. To fix this you need to add an onclick event manully through the DOM and then call the onmouseover event manually, There is a slight difference between browsers to take of also. Check out the solution


var map = null;
var pinID = 1;

function GetMap()
{
    map = new VEMap('myMap');
    map.LoadMap(new VELatLong(47.6, -122.33), 10 ,'h' ,false);

    AddClickablePin(new VELatLong(47.6, -122.33),null,"test","some nice details")
}

function AddClickablePin(location, icon_url, title, details)
{
    var pin = new VEPushpin(pinID, location, icon_url, title, details);
    map.AddPushpin(pin);
    var element = document.getElementById(pinID);
    element.onclick = EventHandlerOnClick;
    pinID++;
}


function EventHandlerOnClick(e)
{
    if (e!=null)
    {
        document.getElementById(e.currentTarget.id + "_" + map.GUID).onmouseover();
    } else
    {
        document.getElementById(window.event.srcElement.id).onmouseover();
    }
}

Tags:

Your name:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment    Cancel