'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.providersMapOptions = exports.providersLayersTypes = undefined;

var _regenerator = require('babel-runtime/regenerator');

var _regenerator2 = _interopRequireDefault(_regenerator);

var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');

var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _basicMapApiClass = require('../util/basicMapApiClass');

var _basicMapApiClass2 = _interopRequireDefault(_basicMapApiClass);

var _tianditu = require('./tianditu');

var _tianditu2 = _interopRequireDefault(_tianditu);

var _baidu = require('./baidu');

var _baidu2 = _interopRequireDefault(_baidu);

var _osm = require('./osm');

var _osm2 = _interopRequireDefault(_osm);

var _bing = require('./bing');

var _bing2 = _interopRequireDefault(_bing);

var _google = require('./google');

var _google2 = _interopRequireDefault(_google);

var _gdmap = require('./gdmap');

var _gdmap2 = _interopRequireDefault(_gdmap);

var _qqmap = require('./qqmap');

var _qqmap2 = _interopRequireDefault(_qqmap);

var _mapbox = require('./mapbox');

var _mapbox2 = _interopRequireDefault(_mapbox);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

// 内置互联网地图服务源的类型枚举名
var providersLayersTypes = exports.providersLayersTypes = {
  tianditu: _tianditu.tdtLayersTypes,
  baidu: _baidu.bdLayersTypes,
  osm: _osm.osmLayersTypes,
  bing: _bing.bingLayersTypes,
  google: _google.googleLayersTypes,
  gdmap: _gdmap.gdLayersTypes,
  qqmap: _qqmap.qqLayersTypes,
  mapbox: _mapbox.mapboxLayersTypes
};

// 内置互联网地图服务源的Map限制Options
/**
 * @文件说明: 构建Map.Providers互联网地图服务源对象
 * @创建人: pjtools@vip.qq.com
 * @创建时间: 2020-03-19 21:10:33
 */

var providersMapOptions = exports.providersMapOptions = {
  tianditu: _tianditu.tdtMapOptions,
  baidu: _baidu.bdMapOptions,
  osm: _osm.osmMapOptions,
  bing: _bing.bingMapOptions,
  google: _google.googleMapOptions,
  gdmap: _gdmap.gdMapOptions,
  qqmap: _qqmap.qqMapOptions,
  mapbox: _mapbox.mapboxMapOptions
};

var Providers = function (_BasicMapApi) {
  (0, _inherits3['default'])(Providers, _BasicMapApi);
  (0, _createClass3['default'])(Providers, [{
    key: 'keys',

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

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

  }]);

  function Providers() {
    var _ref;

    (0, _classCallCheck3['default'])(this, Providers);

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

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

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


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

      var tianditu = new _tianditu2['default'](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 _baidu2['default'](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 _baidu2['default'](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 _osm2['default'](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 _bing2['default'](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 _google2['default'](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 _gdmap2['default'](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 _qqmap2['default'](this.iMapApi);
      var layers = qqmap.getLayers(options);
      qqmap = null;
      return layers;
    }

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

  }, {
    key: 'getMapbox',
    value: function () {
      var _ref2 = (0, _asyncToGenerator3['default'])( /*#__PURE__*/_regenerator2['default'].mark(function _callee() {
        var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
        var mapbox, layers;
        return _regenerator2['default'].wrap(function _callee$(_context) {
          while (1) {
            switch (_context.prev = _context.next) {
              case 0:
                mapbox = new _mapbox2['default'](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 = (0, _asyncToGenerator3['default'])( /*#__PURE__*/_regenerator2['default'].mark(function _callee2(key) {
        var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
        return _regenerator2['default'].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;
}(_basicMapApiClass2['default']);

exports['default'] = Providers;