none
Bing Pushpin reset to default. RRS feed

  • Question

  • Hi

    I have set up a Bingmap which displays locations of buildings and when I click on the icon it changes the pushpin to a different colour. The problem I have is if I then click on another pushpin, the original pin doesnt go back to the default icon, its stays as icon2.

    if (e.targetType == 'pushpin') {
    infobox.setLocation(e.target.getLocation());
    e.target.setOptions({icon:customIcon2});
    map.setView({center:loc, zoom: 8});
    
    infobox.setOptions({ visible: true, title: e.target.Title, titleClickHandler: InfoboxHandler});}
    else
    e.target.setOptions({icon: customIcon});
    }

    any ideas why its not working?

    Thanks

    Wednesday, May 2, 2012 4:11 PM

Answers

  • You have two options. The first is to store a copy of the default pushpin and switch back to that or to simply recreate the pushpin.

    http://rbrundritt.wordpress.com

    Thursday, May 3, 2012 8:52 AM

All replies

  • You have two options. The first is to store a copy of the default pushpin and switch back to that or to simply recreate the pushpin.

    http://rbrundritt.wordpress.com

    Thursday, May 3, 2012 8:52 AM
  • Hi,

    I have stored the original image in a string, that is what customIcon is, it references the path to the original but for some reason it doesnt seem to pick that up.

    When I click on the pushpin, it changes to the new icon but if I then click on another pushpush, it changes the colour of the second pin but doesnt switch the first pin back to the original "off" icon.

    Thursday, May 3, 2012 9:58 AM
  • The reason I have marked this as unanswered is because I have stored a copy of the default pushpin but its not switching back to that when I click on a different pin.

    Just now, if I click on the first pin then that changes to the "on" image, which is perfect but if I then click on a different pin, the first one doesnt switch back to the "off" pin. The second pin does however go to the "on" status.

    So what then happens is I have 2 pins both stuck on the "on" image.

    Monday, May 14, 2012 9:55 AM
  • Hi,

    So how to store a default pushpin icon?

    I tried with getIcon() but it's not working. Returns null.

        var pin_icon;

        Microsoft.Maps.Events.addHandler( pin, "mouseover", pushpinHover );

        Microsoft.Maps.Events.addHandler( pin, "mouseout", function( h )     
        {
            h.target.setOptions(
            {
                color: "rgba(255, 0, 0, 1)",
                icon: pin_icon
            } );
        } );

    function pushpinHover( e ) {

        pin_icon = e.target.getIcon();
        console.log(pin_icon);

    }

    I want to reset a pushpin to a default icon on mouse out.

    How to do this?

    Monday, June 24, 2019 11:20 PM
  • Hi Pablo8,

    You are replying to a thread from 2012. All Bing Maps controls have gone through a number of revisions in that time so I recommend looking at the documentation for the Bing Maps control you are using. See https://www.microsoft.com/en-us/maps/choose-your-bing-maps-api

    If you are using the Web control, take a look at custom icons and event handling in the Interactive SDK at https://www.bing.com/api/maps/sdk/mapcontrol/isdk

    Sincerely,

    IoTGirl

    Tuesday, June 25, 2019 10:37 PM
    Owner