当前位置:网站首页>Further optimize Baidu map data visualization

Further optimize Baidu map data visualization

2022-04-23 17:03:00 Eli-sun

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    html, body{
      height: 100%;
      height: 100%;
      margin: 0;
      padding: 0;
    }
    #map{
      height: 100%;
      width: 100%;
      margin: 0;
      padding: 0;
    }
    .anchorBL, .BMap_cpyCtrl{
display: none;
    }
  </style>
</head>

<body>
  <div id="map"></div>
  <script>
    console.log(window.BMapGL);
    function init(){
      var map = new BMapGL.Map('map') //  Initialize map 
      var point = new BMapGL.Point(116.404,39.915) //  Set map coordinates 
      map.centerAndZoom(point, 10) //  Central   Map display level  
      map.enableScrollWheelZoom(true) //  Zoom in and out of the map through the scroll wheel 
    }
    // onload  Page loading complete 
    window.onload = function() {
      // src="https://api.map.baidu.com/api?v=1.0&type=webgl&ak=cXG18I5SNt2EZNvG7CVyE4jjTr8swlo4"
      var script = document.createElement('script')
      //  To initialize the map, you can src Add one at the end &callback=init   Add one more callback Parameter this parameter points to init Method 
      script.src = "https://api.map.baidu.com/api?v=1.0&type=webgl&ak=cXG18I5SNt2EZNvG7CVyE4jjTr8swlo4&callback=init"
      document.body.appendChild(script)
    }
  </script>
</body>
</html>

版权声明
本文为[Eli-sun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230554289772.html