none
Custom HTML pushpin Not firing any Infobox event in the brower firefox chrome and safari. RRS feed

  • Question

  • <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
       <head>
          <title>Add pushpin with options</title>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
          <script type="text/javascript" src="</script">http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
          <script type="text/javascript">
           var map = null;
           function getMap()
           {
            map = new Microsoft.Maps.Map(document.getElementById('myMap'), { credentials: 'key' });
           }
           function addCustomPushpin()
           {
            var pushpinOptions = { width: null, height: null, htmlContent: "<div style='font-size:12px;font-weight:bold;border:solid 2px;background-color:LightBlue;width:100px;'>Custom Pushpin</div>" };
            var pushpin = new Microsoft.Maps.Pushpin(map.getCenter(), pushpinOptions);
            pushpinLayer = new Microsoft.Maps.EntityCollection();
            map.entities.push(pushpinLayer);
            pushpinLayer.push(pushpin);
            //map.entities.push(pushpin);
            Microsoft.Maps.Events.addHandler(pushpin, 'click', test);
           }
           function test()
           {
            alert("Custom HTML Pushpin.");
      }
          </script>
       </head>
       <body onload="getMap();">
          <div id='myMap' style="; width:400px; height:400px;"></div>
          <div>
             <input type="button" value="AddCustomPushpin" onclick="addCustomPushpin();" />
          </div>
       </body>
    </html>

    I push the pushpin to EntityCollection,the click event can't fire.

    I push the pushpin to map,the click event can work well.

    I test in the brower firefox,chrome and safari.

    Tuesday, June 18, 2013 6:53 AM

Answers

All replies