views:

4213

answers:

2

I have a Virtual Earth Maps (Bing Maps??) to which I have added a set of pushpins. Each pushpin is labelled 1 to n. In addition to adding pushpins to the map, I also add text to the web-page that contains the description to each pushpin.

I would like to add a link to the text outside the map, that when clicked will open the balloon associated with the corresponding pushpin.

How do I open the balloon associated with a pushpin, through a link that exists outside the map?

To get a better understanding, look at my map: link. When you click load, PushPins are added to the map. I would like to have a link from the list on the right of the map, that opens the corresponding PushPin.

Thanks in advance!

+2  A: 

Here's a simple example of adding some shapes to a Map using Bing Maps and showing the "Title" of each Shape in a list next to the Map. Then when the user hovers over each item in the list, it will open the InfoBox for that Shape on the Map.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html>
   <head>
      <title></title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2"&gt;&lt;/script&gt;
      <style type="text/css">
        #ShapeList div
        {
            padding: 4px;
            border: solid 1px black;
        }
      </style>
      <script type="text/javascript">
      var map = null;

      function GetMap()
      {
         map = new VEMap('myMap');
         map.LoadMap();

         // Add some Shapes to the Map with item in list next to map
         var latlong = map.GetCenter();
         AddShape("Test Pushpin", latlong);
         AddShape("Another Pushpin", new VELatLong(latlong.Latitude + 2, latlong.Longitude));
         AddShape("Still Another Pushpin", new VELatLong(latlong.Latitude - 2, latlong.Longitude));
     }

     function AddShape(title, latlong) {
         // Create Pushpin Shape
         var s = new VEShape(VEShapeType.Pushpin, latlong);
         s.SetTitle(title);

         // Add Shape to Map
         map.AddShape(s);

         // Display Item in List Next to Map
         var elem = document.createElement("div");
         elem.innerHTML = title;
         document.getElementById("ShapeList").appendChild(elem);

         var shapeID = s.GetID();
         elem.attachEvent("onmouseover", function() { ShowInfoBoxByShapeID(shapeID); });
         elem.attachEvent("onmouseout", function() { map.HideInfoBox(); });
     }

     function ShowInfoBoxByShapeID(shapeID) {
         var shape = map.GetShapeByID(shapeID);
         map.ShowInfoBox(shape);
     }

      </script>
   </head>
   <body onload="GetMap();">
      <div id="ShapeList" style="float: left">
      </div>
      <div id='myMap' style="position:relative; width:400px; height:400px;"></div>
   </body>
</html>
Chris Pietschmann
This looks like it should work - I will mark your answer as THE answer once I have it tested - thanks.
Rajah
What if you are adding Shapes via server side code.How do you get the Shape ID's?
Jack Marchetti
A: 

How about displaying informaion in popup using Silverlight bing maps ?