'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _index = require('./index.js');

var _index2 = _interopRequireDefault(_index);

var _pluggablemap = require('./pluggablemap.js');

var _pluggablemap2 = _interopRequireDefault(_pluggablemap);

var _plugintype = require('./plugintype.js');

var _plugintype2 = _interopRequireDefault(_plugintype);

var _control = require('./control.js');

var _control2 = _interopRequireDefault(_control);

var _interaction = require('./interaction.js');

var _interaction2 = _interopRequireDefault(_interaction);

var _obj = require('./obj.js');

var _obj2 = _interopRequireDefault(_obj);

var _plugins = require('./plugins.js');

var _plugins2 = _interopRequireDefault(_plugins);

var _imagelayer = require('./renderer/canvas/imagelayer.js');

var _imagelayer2 = _interopRequireDefault(_imagelayer);

var _map = require('./renderer/canvas/map.js');

var _map2 = _interopRequireDefault(_map);

var _tilelayer = require('./renderer/canvas/tilelayer.js');

var _tilelayer2 = _interopRequireDefault(_tilelayer);

var _vectorlayer = require('./renderer/canvas/vectorlayer.js');

var _vectorlayer2 = _interopRequireDefault(_vectorlayer);

var _vectortilelayer = require('./renderer/canvas/vectortilelayer.js');

var _vectortilelayer2 = _interopRequireDefault(_vectortilelayer);

var _imagelayer3 = require('./renderer/webgl/imagelayer.js');

var _imagelayer4 = _interopRequireDefault(_imagelayer3);

var _map3 = require('./renderer/webgl/map.js');

var _map4 = _interopRequireDefault(_map3);

var _tilelayer3 = require('./renderer/webgl/tilelayer.js');

var _tilelayer4 = _interopRequireDefault(_tilelayer3);

var _vectorlayer3 = require('./renderer/webgl/vectorlayer.js');

var _vectorlayer4 = _interopRequireDefault(_vectorlayer3);

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

if (_index2.default.ENABLE_CANVAS) {
  _plugins2.default.register(_plugintype2.default.MAP_RENDERER, _map2.default);
  _plugins2.default.registerMultiple(_plugintype2.default.LAYER_RENDERER, [_imagelayer2.default, _tilelayer2.default, _vectorlayer2.default, _vectortilelayer2.default]);
}

if (_index2.default.ENABLE_WEBGL) {
  _plugins2.default.register(_plugintype2.default.MAP_RENDERER, _map4.default);
  _plugins2.default.registerMultiple(_plugintype2.default.LAYER_RENDERER, [_imagelayer4.default, _tilelayer4.default, _vectorlayer4.default]);
}

/**
 * @classdesc
 * The map is the core component of OpenLayers. For a map to render, a view,
 * one or more layers, and a target container are needed:
 *
 *     var map = new ol.Map({
 *       view: new ol.View({
 *         center: [0, 0],
 *         zoom: 1
 *       }),
 *       layers: [
 *         new ol.layer.Tile({
 *           source: new ol.source.OSM()
 *         })
 *       ],
 *       target: 'map'
 *     });
 *
 * The above snippet creates a map using a {@link ol.layer.Tile} to display
 * {@link ol.source.OSM} OSM data and render it to a DOM element with the
 * id `map`.
 *
 * The constructor places a viewport container (with CSS class name
 * `ol-viewport`) in the target element (see `getViewport()`), and then two
 * further elements within the viewport: one with CSS class name
 * `ol-overlaycontainer-stopevent` for controls and some overlays, and one with
 * CSS class name `ol-overlaycontainer` for other overlays (see the `stopEvent`
 * option of {@link ol.Overlay} for the difference). The map itself is placed in
 * a further element within the viewport.
 *
 * Layers are stored as a `ol.Collection` in layerGroups. A top-level group is
 * provided by the library. This is what is accessed by `getLayerGroup` and
 * `setLayerGroup`. Layers entered in the options are added to this group, and
 * `addLayer` and `removeLayer` change the layer collection in the group.
 * `getLayers` is a convenience function for `getLayerGroup().getLayers()`.
 * Note that `ol.layer.Group` is a subclass of `ol.layer.Base`, so layers
 * entered in the options or added with `addLayer` can be groups, which can
 * contain further groups, and so on.
 *
 * @constructor
 * @extends {ol.PluggableMap}
 * @param {olx.MapOptions} options Map options.
 * @fires ol.MapBrowserEvent
 * @fires ol.MapEvent
 * @fires ol.render.Event#postcompose
 * @fires ol.render.Event#precompose
 * @api
 */
var _ol_Map_ = function (options) {
  options = _obj2.default.assign({}, options);
  if (!options.controls) {
    options.controls = _control2.default.defaults();
  }
  if (!options.interactions) {
    options.interactions = _interaction2.default.defaults();
  }

  _pluggablemap2.default.call(this, options);
};

_index2.default.inherits(_ol_Map_, _pluggablemap2.default);
exports.default = _ol_Map_;
module.exports = exports['default'];