// 内库使用-start
import AssetUtil from "../../../../../utils/AssetUtil";
// 内库使用-end

/* 测试使用-start
import { AssetUtil } from 'seedsui-react'
测试使用-end */

// 加载google地图资源
function loadGoogle(key) {
  return new Promise(function (resolve) {
    if (window.google) {
      resolve(window.google);
      return;
    }

    // Delete old script
    var scriptTag = document.getElementById('google-map-js');
    if (scriptTag) {
      scriptTag.parentNode.removeChild(scriptTag);
    }

    // Load js
    AssetUtil.loadJs("https://maps.googleapis.com/maps/api/js?key=".concat(key), {
      id: 'google-map-js',
      success: function success() {
        resolve(window.google);
      },
      fail: function fail() {
        resolve("google\u5730\u56FE\u52A0\u8F7D\u5931\u8D25");
      }
    });
  });
}
export default loadGoogle;