import _regeneratorRuntime from 'babel-runtime/regenerator';
import _asyncToGenerator from 'babel-runtime/helpers/asyncToGenerator';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _createClass from 'babel-runtime/helpers/createClass';
import _inherits from 'babel-runtime/helpers/inherits';
/**
 * @文件说明: 构建Map.Providers互联网地图服务源对象
 * @创建人: pjtools@vip.qq.com
 * @创建时间: 2020-03-19 21:10:33
 */

import BasicMapApi from '../util/basicMapApiClass';
import Tianditu, { tdtLayersTypes, tdtMapOptions } from './tianditu';
import Baidu, { bdLayersTypes, bdMapOptions } from './baidu';
import OSM, { osmLayersTypes, osmMapOptions } from './osm';
import Bing, { bingLayersTypes, bingMapOptions } from './bing';
import Google, { googleLayersTypes, googleMapOptions } from './google';
import GDMap, { gdLayersTypes, gdMapOptions } from './gdmap';
import QQMap, { qqLayersTypes, qqMapOptions } from './qqmap';
import Mapbox, { mapboxLayersTypes, mapboxMapOptions } from './mapbox';

// 内置互联网地图服务源的类型枚举名
export var providersLayersTypes = {
  tianditu: tdtLayersTypes,
  baidu: bdLayersTypes,
  osm: osmLayersTypes,
  bing: bingLayersTypes,
  google: googleLayersTypes,
  gdmap: gdLayersTypes,
  qqmap: qqLayersTypes,
  mapbox: mapboxLayersTypes
};

// 内置互联网地图服务源的Map限制Options
export var providersMapOptions = {
  tianditu: tdtMapOptions,
  baidu: bdMapOptions,
  osm: osmMapOptions,
  bing: bingMapOptions,
  google: googleMapOptions,
  gdmap: gdMapOptions,
  qqmap: qqMapOptions,
  mapbox: mapboxMapOptions
};

var Providers = function (_BasicMapApi) {
  _inherits(Providers, _BasicMapApi);

  _createClass(Providers, [{
    key: 'keys',

    /**
     * 获取互联网地图服务源名称
     * @readonly
     */
    get: function get() {
      return Object.keys(providersLayersTypes);
    }

    /**
     * Providers地图服务源
     * @param {MapApi} iMapApi 地图Api实例化对象
     */

  }]);

  function Providers() {
    var _ref;

    _classCallCheck(this, Providers);

    for (var _len = arguments.length, arg = Array(_len), _key = 0; _key < _len; _key++) {
      arg[_key] = arguments[_key];
    }

    return _possibleConstructorReturn(this, (_ref = Providers.__proto__ || Object.getPrototypeOf(Providers)).call.apply(_ref, [this].concat(arg)));
  }

  /**
   * 获取天地图在线服务源的图层数据集合
   * @param {Object} options 服务源的参数选项
   */


  _createClass(Providers, [{
    key: 'getTianditu',
    value: function getTianditu() {
      var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

      var tianditu = new Tianditu(this.iMapApi);
      var layers = tianditu.getLayers(options);
      tianditu = null;
      return layers;
    }

    /**
     * 获取百度在线服务源的图层数据集合
     * @param {Object} options 服务源的参数选项
     */

  }, {
    key: 'getBaidu',
    value: function getBaidu() {
      var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

      var baidu = new Baidu(this.iMapApi);
      var layers = baidu.getLayers(options);
      baidu = null;
      return layers;
    }

    /**
     * 添加百度的交通实时路况的图层
     * @param {String} id 图层Id名称
     */

  }, {
    key: 'addBaiduTrafficLayer',
    value: function addBaiduTrafficLayer(id, beforeId) {
      var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

      var baidu = new Baidu(this.iMapApi);
      var layer = baidu.getTrafficLayer(id, options);
      baidu = null;
      return this.iMapApi.addLayer(layer, beforeId);
    }

    /**
     * 获取OSM在线服务源的图层数据集合
     * @param {Object} options 服务源的参数选项
     */

  }, {
    key: 'getOSM',
    value: function getOSM() {
      var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

      var osm = new OSM(this.iMapApi);
      var layers = osm.getLayers(options);
      osm = null;
      return layers;
    }

    /**
     * 获取Bing在线服务源的图层数据集合
     * @param {Object} options 服务源的参数选项
     */

  }, {
    key: 'getBing',
    value: function getBing() {
      var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

      var bing = new Bing(this.iMapApi);
      var layers = bing.getLayers(options);
      bing = null;
      return layers;
    }

    /**
     * 获取Google在线服务源的图层数据集合
     * @param {Object} options 服务源的参数选项
     */

  }, {
    key: 'getGoogle',
    value: function getGoogle() {
      var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

      var google = new Google(this.iMapApi);
      var layers = google.getLayers(options);
      google = null;
      return layers;
    }

    /**
     * 获取高德在线服务源的图层数据集合
     * @param {Object} options 服务源的参数选项
     */

  }, {
    key: 'getGDMap',
    value: function getGDMap() {
      var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

      var gdmap = new GDMap(this.iMapApi);
      var layers = gdmap.getLayers(options);
      gdmap = null;
      return layers;
    }

    /**
     * 获取腾讯在线服务源的图层数据集合
     * @param {Object} options 服务源的参数选项
     */

  }, {
    key: 'getQQMap',
    value: function getQQMap() {
      var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

      var qqmap = new QQMap(this.iMapApi);
      var layers = qqmap.getLayers(options);
      qqmap = null;
      return layers;
    }

    /**
     * 获取MapboxGL在线服务源的图层数据集合
     * @param {Object} options 服务源的参数选项
     */

  }, {
    key: 'getMapbox',
    value: function () {
      var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
        var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
        var mapbox, layers;
        return _regeneratorRuntime.wrap(function _callee$(_context) {
          while (1) {
            switch (_context.prev = _context.next) {
              case 0:
                mapbox = new Mapbox(this.iMapApi);
                _context.next = 3;
                return mapbox.getLayers(options);

              case 3:
                layers = _context.sent;

                mapbox = null;
                return _context.abrupt('return', layers);

              case 6:
              case 'end':
                return _context.stop();
            }
          }
        }, _callee, this);
      }));

      function getMapbox() {
        return _ref2.apply(this, arguments);
      }

      return getMapbox;
    }()

    /**
     * 根据对应内置的服务源Key名获取服务源图层数据
     * @param {String} key 内置服务源Key名
     * @param {Object} options 服务源的参数选项
     */

  }, {
    key: 'getProvidersLayers',
    value: function () {
      var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(key) {
        var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
        return _regeneratorRuntime.wrap(function _callee2$(_context2) {
          while (1) {
            switch (_context2.prev = _context2.next) {
              case 0:
                _context2.t0 = key;
                _context2.next = _context2.t0 === 'tianditu' ? 3 : _context2.t0 === 'baidu' ? 4 : _context2.t0 === 'osm' ? 5 : _context2.t0 === 'bing' ? 6 : _context2.t0 === 'google' ? 7 : _context2.t0 === 'gdmap' ? 8 : _context2.t0 === 'qqmap' ? 9 : _context2.t0 === 'mapbox' ? 10 : 11;
                break;

              case 3:
                return _context2.abrupt('return', this.getTianditu(options));

              case 4:
                return _context2.abrupt('return', this.getBaidu(options));

              case 5:
                return _context2.abrupt('return', this.getOSM(options));

              case 6:
                return _context2.abrupt('return', this.getBing(options));

              case 7:
                return _context2.abrupt('return', this.getGoogle(options));

              case 8:
                return _context2.abrupt('return', this.getGDMap(options));

              case 9:
                return _context2.abrupt('return', this.getQQMap(options));

              case 10:
                return _context2.abrupt('return', this.getMapbox(options));

              case 11:
                return _context2.abrupt('return', null);

              case 12:
              case 'end':
                return _context2.stop();
            }
          }
        }, _callee2, this);
      }));

      function getProvidersLayers(_x11) {
        return _ref3.apply(this, arguments);
      }

      return getProvidersLayers;
    }()
  }]);

  return Providers;
}(BasicMapApi);

export default Providers;