码迷,mamicode.com
首页 > Windows程序 > 详细

JS调用百度地图API标记地点

时间:2017-06-23 18:23:48      阅读:275      评论:0      收藏:0      [点我收藏+]

标签:api   lzo   百度   charset   font   缩放   6.4   logs   密钥   

<!DOCTYPE html>
<html>
<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,#allmap {width: 100%;height: 100%;margin:0;font-family:"微软雅黑";font-size:14px;}
        #l-map{height:500px;width:100%;}
        #r-result{width:100%;}
    </style>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=您的密钥"></script>
    <title>获取信息窗口的信息</title>
</head>
<body>
    <div id="l-map"></div>
    <div id="r-result"></div>
</body>
</html>
<script type="text/javascript">
    // 百度地图API功能
    var sContent ="天安门坐落在中国北京市中心,故宫的南侧,与天安门广场隔长安街相望,是清朝皇城的大门...";
    var map = new BMap.Map("l-map");
    var point = new BMap.Point(116.404, 39.915);
    map.centerAndZoom(point, 15);
    var infoWindow = new BMap.InfoWindow(sContent);  // 创建信息窗口对象
    map.openInfoWindow(infoWindow,point); //开启信息窗口
        map.enableScrollWheelZoom();//启动鼠标滚轮缩放地图
    document.getElementById("r-result").innerHTML = "信息窗口的内容是:<br />" + infoWindow.getContent();
</script>

 

JS调用百度地图API标记地点

标签:api   lzo   百度   charset   font   缩放   6.4   logs   密钥   

原文地址:http://www.cnblogs.com/supe/p/7070936.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!