none
PushPin Events AJAX V7 RRS feed

  • Question

  • Hi,

    How do i get/setup pushpin events when the user clicks on a specfic pushpin?

    Note i am using HTML java scrip and AJAX V7

    Thanks,

    Dora-9


    Student [Visual C#.Net / VB.Net]
    • Moved by Ricky_Brundritt Friday, March 9, 2012 1:35 PM (From:Bing Maps: Map Control and Web services Development)
    Thursday, January 6, 2011 3:39 PM

Answers

  • HI,

     

    I have to say the documentation for V7 is RUBBISH. i have finally found out how this is done: -

    function AddPushpin(latitude, longitude) {
    
      // Define the pushpin location
      var loc = new Microsoft.Maps.Location(latitude, longitude);
    			
      // Add a pin to the map
      var pin = new Microsoft.Maps.Pushpin(loc, { text: '1' });
      map.entities.push(pin);
    
      // Add pushpin event handler
      Microsoft.Maps.Events.addHandler(pin, 'click', onPush);
    
      // Center the map on the location
      map.setView({ center: loc });
    
    }
    

    When i remove the said pushpin do i also need to manually remove the event handler or is this done for me?

    function onPush(e) {
     if (e.targetType = "map") {
    
     try {
      // Get Pin 
      var pin = e.target;
      //Debug code
      alert("Pin = " + pin.getText());
      // Remove pin ** do i need to remove the event handler before this line **
      map.entities.remove(pin);
    
      //window.external.onPush("PushPin");
      } catch (e) {
      alert("Broken = " + e);
      }
     }
    }
    

    Thanks,

    Dora-9

     


    Student [Visual C#.Net / VB.Net]
    Thursday, January 6, 2011 4:29 PM