百度地图显示并标注

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>gis地图</title>

<style type="text/css">  
html{height:100%}  
body{height:100%;margin:0px;padding:0px}  
#container{height:100%}  
</style>  
<script type="text/javascript" src="jquery.js"></script>

<!--从百度地图API获取密钥-->
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.5&ak=YzXwdBawjM5AmKc8IkVMhdoX"></script>

</head>

<body id="fremhieght">
    <div id="container"></div>
</body>
</html>
<script type="text/javascript">
    var map = new BMap.Map("container");          // 创建地图实例  
    var point = new BMap.Point(118.790596, 32.048009);  // 创建点坐标  
    var point2 = new BMap.Point(118.782386, 32.048912);
    map.centerAndZoom(point, 15);                 // 初始化地图,设置中心点坐标和地图级别  
    map.enableScrollWheelZoom();
    var marker2 = new BMap.Marker(point2); // 创建标注
    var marker = new BMap.Marker(point); // 创建标注
    map.addOverlay(marker);
    map.addOverlay(marker2);
    //添加标记点击监听  
    marker.addEventListener("click", function(){
        this.openInfoWindow(new BMap.InfoWindow('<h3>新街口地铁站</h3><p style="width:280px;margin:0;line-height:20px;font-size:12px;">地址:江苏省南京市秦淮区中山南路3号<br/>电话:123456</p>', {
          width : 250,     // 信息窗口宽度
          height: 100,     // 信息窗口高度
          //title : "学校地址:"  // 信息窗口标题
        })
        );
    })      
</script>

posted on 2014-06-22 17:47  cc_java  阅读(439)  评论(0编辑  收藏  举报

导航