none
Infobox events issue - v7 RRS feed

  • Question

  • In working with the available events for the Infobox object, I came across an issue.  It seems that the events only fire for the first use and not any subsequent actions that should fire the event. Here is some code:

    Create the Infobox:

    var infoboxOptions = { visible: false, offset: new Microsoft.Maps.Point(0, 20), title: "Title", zIndex: 1000 };
    pinInfobox = new Microsoft.Maps.Infobox(center, infoboxOptions);

    Set the event:

     Microsoft.Maps.Events.addHandler(pinInfobox, 'mouseleave', hideInfobox);
    

    When the map is loaded a pin is added to the map.  The "click" event is registered for the pin and the supporting logic for the event displays the infobox.  When you mouse over and out of the infobox, the infobox closes as planned.

    In repeating the steps, the infobox opens, but when you mouse out (mouseleave event) the event does not fire and the supporting code to close the infobox does not execute.

    I tried this with both IE 9 (compatibility mode) and FF4 and got the same result.  Please let me know if you have any thoughts on this.

    Thanks,

    Mike Garza
    http://www.garzilla.net/vemaps

     

    • Moved by Ricky_Brundritt Friday, March 9, 2012 5:04 PM (From:Bing Maps: Map Control and Web services Development)
    Friday, April 8, 2011 1:45 PM

Answers

  • Hi Mike,

    Indeed, I managed to get the same result. It's a little bit awkward, it seems like the pinInfoBox is disposed.

    Anyway, here is a small temporary solution but we should definetly invest to know what is the reason of this bug:

    		function displayInfobox(e)
    		{			
    			pinInfobox = new Microsoft.Maps.Infobox(new Microsoft.Maps.Location(0,0), {title: 'My Pushpin', visible: true});
    			map.entities.push(pinInfobox);
    			Microsoft.Maps.Events.addHandler(pinInfobox, 'mouseleave', hideInfobox);
    		}
    				
    
    		function hideInfobox(e)
    		{
    			pinInfobox.setOptions({ visible: false });
    			map.entities.remove(pinInfoBox);
    		}
    
    

    The things is to change the way the infoBox is generated, I create the infoBox on the click on the pin and in the click I add the handler to close the infoBox on mouseleave. So my pinInfoBox's event's are associated.

    It's weird, I will invest the infoBox event asap. Let us know if you find something.


    MVP - Bing Maps - My blog (FR): http://blogs.developpeur.org/nicoboo/ Twitter: http://twitter.com/nicolasboonaert/
    Friday, April 8, 2011 4:57 PM
    Moderator