none
Removing PushPins v7 RRS feed

  • Question

  • Hi All,

    I have a map that I add pushpins to.  This all works fine, but when I come to do my driving directions, I can't seem to be able to remove the pushpins.  

    This is the code I have

    function deletePushpin()
    
          {
    
              for(var i=map.entities.getLength()-1;i>=0;i--) 
    
              {
    
                  var pushpin= map.entities.get(i); 
    
                  if (pushpin instanceof Microsoft.Maps.Pushpin) { 
    
                    map.entities.Remove(pushpin);  
                  
                  }
    
               } 
    
            
    
          }
    

    The above does nothing, and I'm not sure where I'm going wrong.  I've also tried map.entities.RemoveAt(i); and that doesn't work either.

    Any help would be very much appreicated.

    Thanks

    • Moved by Ricky_Brundritt Saturday, March 10, 2012 12:16 PM (From:Bing Maps: Map Control and Web services Development)
    Tuesday, September 13, 2011 8:03 PM

Answers

  • I recommend using EntityCollections and putting your data in those. Use different entity collections to store Pushpins. Then use the clear method to remove the pushpins in the layer.
    http://rbrundritt.wordpress.com
    • Marked as answer by Thunderchild Tuesday, September 13, 2011 10:31 PM
    Tuesday, September 13, 2011 9:56 PM

All replies

  • I recommend using EntityCollections and putting your data in those. Use different entity collections to store Pushpins. Then use the clear method to remove the pushpins in the layer.
    http://rbrundritt.wordpress.com
    • Marked as answer by Thunderchild Tuesday, September 13, 2011 10:31 PM
    Tuesday, September 13, 2011 9:56 PM
  • Thanks, the clear method worked a treat.  I was already using an EntityCollection, I just wasn't using the clear method.

     

    Thanks again

    Tuesday, September 13, 2011 10:33 PM
  • In your if block u should change 

    map.entites.Remove(pushpin);  ==> map.entities.removeAt(i);

     

    Tuesday, November 22, 2011 2:14 AM