vue使用百度地图

// bmpgl.js
export function BMPGL(ak) {
    return new Promise(function(resolve, reject) {
      window.init = function() {
        // eslint-disable-next-line
        resolve(BMapGL)
      }
      const script = document.createElement('script')
      script.type = 'text/javascript'
      script.src = `http://api.map.baidu.com/api?v=3.0&type=webgl&ak=${ak}&callback=init`
      script.onerror = reject
      document.head.appendChild(script)
    })
  }
import { BMPGL } from "@/utils/bmpgl.js";
 BMPGL(this.ak).then((BMapGL) => {
          let map = new BMapGL.Map("container");
          let point = new BMapGL.Point(centerLat, centerRat);
          map.centerAndZoom(new BMapGL.Point(centerLat, centerRat), 15);
          //开启鼠标滚轮缩放
          map.enableScrollWheelZoom(true);
          })
        .catch((err) => {
          console.log(err);
        });
上一篇:百度地图API的使用(JavaScript版)


下一篇:百度地图(26)-矢量图标