Quantcast
Channel: 石家庄网络公司_网站建设公司_石家庄网站制作价格 » Bing
Viewing all articles
Browse latest Browse all 5

必应(bing)地图应用实例

$
0
0

微软必应地图API发布了,新手不好入门,这里领头羊网络以简单易懂的方式给大家一个Bing Maps API的演示示例,希望能对那些开发不怎么熟悉的人有所帮助。

功能:显示地图,显示坐标,显示描述文字

不多废话,上代码:

提示:你可以先修改部分代码再运行。

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<title>必应(bing)地图应用实例</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>
<style>
img{
 border:0;/*地图中调用的是本地网页的CSS*/
}
</style>
<script type=”text/javascript” src=”http://dev.ditu.live.com/mapcontrol/mapcontrol.ashx?v=6.1″></script>
<script type=”text/javascript”>
  var map = null;
  var lat1 = 38.035842; //坐标
  var lon1 = 114.378077;//坐标
  var latLong=new VELatLong(lat1,lon1);
  function GetMap()
  {
  map = new VEMap(‘myMap’);
  map.LoadMap();
  AddPushpin();
  map.SetCenterAndZoom(latLong, 13);//13代表缩放大小,自己改一下一试就明白了。
  }
  function AddPushpin()
   {
    var shape = new VEShape(VEShapeType.Pushpin, latLong);
    shape.SetTitle(“<span style=’color:red’><b>领头羊网络</b></span>”);//标题,可以加HTML。
    shape.SetDescription(“<span style=’color:green’>网站建设、开发、推广<br><span style=’color:blue’><b>首选领头羊品牌!</b></span></span><br><br><b>网址:</b><br><span style=’color:green;’><a target=’_blank’ href=’http://www.lty0311.com’>www.lty0311.com</a></span>”);//描述内容,可以加HTML。
    //shape.SetMoreInfoURL(‘http://www.lty0311.com’); //将此行前的//去掉,可以在描述后面加网址链接。
    shape.SetPhotoURL(‘http://www.lty0311.com/images/80-80.png’);//加自己的LOGO,大小为80*80像素。
    map.AddShape(shape);
   }
</script>
</head>
<body onload=”GetMap();”>
<div id=’myMap’ style=”position:relative; width:555px; height:388px;”>领头羊网络提示:地图正在加载,请耐心等候…</div>
</body>
</html>


Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images