none
How can i add multiple pushpins RRS feed

  • Question

  •  

    I have to add multiple pushpins in my map . i pass different latitudes and longitudes .Can any one post the code
    • Moved by Ricky_Brundritt Friday, March 16, 2012 6:31 PM (From:Bing Maps: Map Control and Web services Development)
    Tuesday, March 11, 2008 10:38 AM

Answers

  • If you can create an array of pushpins and add them all at once using the VEMap.AddShape method. This method will add either one VEShape or an Array of VEShapes. The following is an example of how this can be done:

    Code Snippet

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
       <head>
          <title></title>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
          <script src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6"></script>
          <script>
        var map = null;
                   
         function GetMap()
         {
              map = new VEMap('myMap');
              map.LoadMap();
              addPins();
         }
        
         function addPins()
         {
              var latlongs = new Array(new VELatLong(45,-110),new VELatLong(45,-114),new VELatLong(45,-90),new VELatLong(45,-95));  
              var pins = new Array();
             
              for(var i=0;i<latlongs.length;i++)
              {
                 pins.push(new VEShape(VEShapeType.Pushpin,latlongs[i]));    
              }
             
              map.AddShape(pins);
         }
    </script>
    </head>
       <body onload="GetMap();">
          <div align="left" id='myMap' style="position:relative; width:600px; height:400px;"></div>
       </body>
    </html>


    Tuesday, March 11, 2008 1:02 PM

All replies

  • If you can create an array of pushpins and add them all at once using the VEMap.AddShape method. This method will add either one VEShape or an Array of VEShapes. The following is an example of how this can be done:

    Code Snippet

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
       <head>
          <title></title>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
          <script src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6"></script>
          <script>
        var map = null;
                   
         function GetMap()
         {
              map = new VEMap('myMap');
              map.LoadMap();
              addPins();
         }
        
         function addPins()
         {
              var latlongs = new Array(new VELatLong(45,-110),new VELatLong(45,-114),new VELatLong(45,-90),new VELatLong(45,-95));  
              var pins = new Array();
             
              for(var i=0;i<latlongs.length;i++)
              {
                 pins.push(new VEShape(VEShapeType.Pushpin,latlongs[i]));    
              }
             
              map.AddShape(pins);
         }
    </script>
    </head>
       <body onload="GetMap();">
          <div align="left" id='myMap' style="position:relative; width:600px; height:400px;"></div>
       </body>
    </html>


    Tuesday, March 11, 2008 1:02 PM
  • Hi Richard

     

    This code is similar to what i need...but my longitudes  and latitudes are provided by  a gridview..gvCustomers...

     

    How can i use it to get multiple pushpins for each customer..Thank you

    Friday, September 9, 2011 9:57 PM
  • This post looks extremely familiar: http://rbrundritt.wordpress.com/2011/10/13/multiple-pushpins-and-infoboxes-in-bing-maps-v7/ 

    http://rbrundritt.wordpress.com

    Sunday, February 12, 2012 6:19 PM