2012-04-05 60 views

回答

1

下面是一個例子:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html> 
    <head> 
     <title>Infobox set location</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=7.0"></script> 
     <script type="text/javascript"> 
     var map = null; 

     function getMap() 
     { 
     map = new Microsoft.Maps.Map(document.getElementById('myMap'), {credentials: 'Your Bing Maps Key'}); 
     } 

     function setInfoBoxLocation() 
     { 
     map.entities.clear();   
     var infoboxOptions = {width :200, height :100, showCloseButton: true, zIndex: 0, offset:new Microsoft.Maps.Point(10,0), showPointer: true, title:'Infobox Title', description:'Infobox description' }; 
     var defaultInfobox = new Microsoft.Maps.Infobox(map.getCenter(), infoboxOptions);  
     map.entities.push(defaultInfobox); 
     defaultInfobox.setLocation(new Microsoft.Maps.Location(47.4, -122.33)); 
     } 
     </script> 
    </head> 
    <body onload="getMap();"> 
     <div id='myMap' style="position:relative; width:400px; height:400px;"></div> 
     <div> 
     <input type="button" value="SetInfoBoxLocation" onclick="setInfoBoxLocation();" /> 
     </div> 
    </body> 
</html> 

下面是一些例子:http://www.bingmapsportal.com/ISDK/AjaxV7