乐趣区

关于前端:js-展示百度地图及添加标注

百度地图开放平台:
https://lbsyun.baidu.com/

新建利用

js 开发文档:

https://lbsyun.baidu.com/index.php?title=jspopularGL

咱们临时用的就是展现地图和标注:源码如下(ak 换一下)

<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="utf-8">
  <title> 地图展现 </title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge">
  <style>
    body,
    html,
    #container {
      overflow: hidden;
      width: 70%;
      height: 70%;
      margin: 0;
      font-family: "微软雅黑";
    }

    .info {
      z-index: 999;
      width: auto;
      min-width: 22rem;
      padding: .75rem 1.25rem;
      margin-left: 1.25rem;
      position: fixed;
      top: 1rem;
      background-color: #fff;
      border-radius: .25rem;
      font-size: 14px;
      color: #666;
      box-shadow: 0 2px 6px 0 rgba(27, 142, 236, 0.5);
    }
  </style>
  <script src="http://api.map.baidu.com/api?type=webgl&v=1.0&ak=yourApplicationKey"></script>
</head>

<body>
  <div class="info"> 最新版 GL 地图命名空间为 BMapGL, 可按住鼠标右键管制地图旋转、批改歪斜角度。</div>
  <div id="container"></div>
</body>

</html>
<script>
  var map = new BMapGL.Map('container'); // 创立 Map 实例
  var point = new BMapGL.Point(116.404, 39.915);
  map.centerAndZoom(point, 15); // 初始化地图, 设置中心点坐标和地图级别
  var marker = new BMapGL.Marker(point); // 创立标注   
  map.addOverlay(marker);
  map.enableScrollWheelZoom(true); // 开启鼠标滚轮缩放
</script>
退出移动版