# all files / ol/layer/ tile.js

100% Statements 25/25
66.67% Branches 4/6
100% Functions 5/5
100% Lines 25/25

    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×
    38×

    38×

    38×
    38×
    38×

    38×
    38×

    38×

    1×

    1×
    62×

    1×

    1×
    38×

    1×
    481×

    1×
    38×

     goog.provide('ol.layer.Tile');

    goog.require('ol');
    goog.require('ol.LayerType');
    goog.require('ol.layer.Layer');
    goog.require('ol.layer.TileProperty');
    goog.require('ol.obj');

    /**
     * @classdesc
     * For layer sources that provide pre-rendered, tiled images in grids that are
     * organized by zoom levels for specific resolutions.
     * Note that any property set in the options is set as a {@link ol.Object}
     * property on the layer object; for example, setting `title: 'My Title'` in the
     * options means that `title` is observable, and has get/set accessors.
     *
     * @constructor
     * @extends {ol.layer.Layer}
     * @fires ol.render.Event
     * @param {olx.layer.TileOptions=} opt_options Tile layer options.
     * @api
     */
    ol.layer.Tile = function(opt_options) {
      var options = opt_options ? opt_options : {};

      var baseOptions = ol.obj.assign({}, options);

      delete baseOptions.preload;
      delete baseOptions.useInterimTilesOnError;
      ol.layer.Layer.call(this,  /** @type {olx.layer.LayerOptions} */ (baseOptions));

      this.setPreload(options.preload !== undefined ? options.preload : 0);
      this.setUseInterimTilesOnError(options.useInterimTilesOnError !== undefined ?
        options.useInterimTilesOnError : true);

      /**
       * The layer type.
       * @protected
       * @type {ol.LayerType}
       */
      this.type = ol.LayerType.TILE;

    };
    ol.inherits(ol.layer.Tile, ol.layer.Layer);

    /**
     * Return the level as number to which we will preload tiles up to.
     * @return {number} The level to preload tiles up to.
     * @observable
     * @api
     */
    ol.layer.Tile.prototype.getPreload = function() {
      return /** @type {number} */ (this.get(ol.layer.TileProperty.PRELOAD));
    };

    /**
     * Return the associated {@link ol.source.Tile tilesource} of the layer.
     * @function
     * @return {ol.source.Tile} Source.
     * @api
     */
    ol.layer.Tile.prototype.getSource;

    /**
     * Set the level as number to which we will preload tiles up to.
     * @param {number} preload The level to preload tiles up to.
     * @observable
     * @api
     */
    ol.layer.Tile.prototype.setPreload = function(preload) {
      this.set(ol.layer.TileProperty.PRELOAD, preload);
    };

    /**
     * Whether we use interim tiles on error.
     * @return {boolean} Use interim tiles on error.
     * @observable
     * @api
     */
    ol.layer.Tile.prototype.getUseInterimTilesOnError = function() {
      return /** @type {boolean} */ (
        this.get(ol.layer.TileProperty.USE_INTERIM_TILES_ON_ERROR));
    };

    /**
     * Set whether we use interim tiles on error.
     * @param {boolean} useInterimTilesOnError Use interim tiles on error.
     * @observable
     * @api
     */
    ol.layer.Tile.prototype.setUseInterimTilesOnError = function(useInterimTilesOnError) {
      this.set(
          ol.layer.TileProperty.USE_INTERIM_TILES_ON_ERROR, useInterimTilesOnError);
    };