jquery
当前位置:长沙网站制作 > 建站知识 > jquery >
百度地图创建使用javascript代码
发布时间:2014-06-11 16:14   来源:长沙网站制作   点击:次   字体:    
百度地图创建使用javascript代码

<!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>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
body, html,#container {width: 100%;height: 100%;overflow: hidden;margin:0;}
</style>
</head>

<body>

<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.2"></script>
<div style="width:100%;height:100%;border:1px solid gray" id="container"></div>
<script type="text/javascript">
var sContent =
"<h4 style='margin:0 0 5px 0;padding:0.2em 0'>{$tit}</h4>" +
"<img style='float:right;margin:4px' id='imgDemo' src='{$titlepic}' width='139' height='104'/>" +
"<p style='margin:0;line-height:1.5;font-size:13px;text-indent:2em;width:70px;'>{$ad}&nbsp;{$tp}&nbsp;{$tc}</p>" +
"</div>";
var map = new BMap.Map("container");
var point = new BMap.Point(113.023195,28.203968);
var marker = new BMap.Marker(point);
var infoWindow = new BMap.InfoWindow(sContent);

map.addControl(new BMap.NavigationControl());
map.enableScrollWheelZoom();     

map.centerAndZoom(point, 19);
map.addOverlay(marker);

marker.addEventListener("click", function(){         
   this.openInfoWindow(infoWindow);
   document.getElementById('imgDemo').onload = function (){
       infoWindow.redraw();
   }
});
</script>

</body>
</html>


关键字:百度,地图,创建,使用,javascript,代码,百度,地

顶一下
(0)
0%
踩一下
(0)
0%
网站对话
web chat