# all files / ol/ map.js

100% Statements 31/31
75% Branches 6/8
100% Functions 1/1
100% Lines 31/31

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    1011×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×

    1×
    312×
    312×
    305×

    312×
    305×

    312×

    1×
     goog.provide('ol.Map');

    goog.require('ol');
    goog.require('ol.PluggableMap');
    goog.require('ol.PluginType');
    goog.require('ol.control');
    goog.require('ol.interaction');
    goog.require('ol.obj');
    goog.require('ol.plugins');
    goog.require('ol.renderer.canvas.ImageLayer');
    goog.require('ol.renderer.canvas.Map');
    goog.require('ol.renderer.canvas.TileLayer');
    goog.require('ol.renderer.canvas.VectorLayer');
    goog.require('ol.renderer.canvas.VectorTileLayer');
    goog.require('ol.renderer.webgl.ImageLayer');
    goog.require('ol.renderer.webgl.Map');
    goog.require('ol.renderer.webgl.TileLayer');
    goog.require('ol.renderer.webgl.VectorLayer');

    Eif (ol.ENABLE_CANVAS) {
      ol.plugins.register(ol.PluginType.MAP_RENDERER, ol.renderer.canvas.Map);
      ol.plugins.registerMultiple(ol.PluginType.LAYER_RENDERER, [
        ol.renderer.canvas.ImageLayer,
        ol.renderer.canvas.TileLayer,
        ol.renderer.canvas.VectorLayer,
        ol.renderer.canvas.VectorTileLayer
      ]);
    }

    Eif (ol.ENABLE_WEBGL) {
      ol.plugins.register(ol.PluginType.MAP_RENDERER, ol.renderer.webgl.Map);
      ol.plugins.registerMultiple(ol.PluginType.LAYER_RENDERER, [
        ol.renderer.webgl.ImageLayer,
        ol.renderer.webgl.TileLayer,
        ol.renderer.webgl.VectorLayer
      ]);
    }

    /**
     * @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
     */
    ol.Map = function(options) {
      options = ol.obj.assign({}, options);
      if (!options.controls) {
        options.controls = ol.control.defaults();
      }
      if (!options.interactions) {
        options.interactions = ol.interaction.defaults();
      }

      ol.PluggableMap.call(this, options);
    };
    ol.inherits(ol.Map, ol.PluggableMap);