How to show the pop up on click of push pin?

Hi,

I am using custom pushpins in my VEMap. Also i am able to get the custom pop up on mouse over.

But my requirement is to show the pop up only on click of the push pin. I don't want to show the pop up on mouse over or on call back event.

Can anyone please help me to overcome my problem



Answer this question

How to show the pop up on click of push pin?

  • Tryst

    Its a real pain but there is an easy solution:

    http://viavirtualearth.com/Wiki/ClickablePin.ashx

    function AddClickablePin(location, icon_url, title, details, iconStyle)
    {
    var pin = new VEPushpin(pinID, location, icon_url, title, details, iconStyle);
    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();
    }
    }

    John.



  • sqlexpressbeginner

    So I am guessing this allows the code to work if you don't want the popup to appear on mouseover at all

    You could refactor your code and move the repeated line "..Over=false" below the if()else.

    I like to help. I'm lucky to be working on VE full time ATM.

    You can mark the answers as green to make it easier for others to search in the future also.

    You can add your version to the WIKI if you a moment, no login required.

    John.



  • Kartit

    Hi John,

    Thanks for your great help!!

    I modified the function as pasted below:

    function EventHandlerOnClick(e)

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

    Becoz it was showing the mouseover behaviour after the first click. I thought of puttting this code snippet so that others arfe benefitted:)

    Anyway once again thanks for ur help and time.


  • How to show the pop up on click of push pin?