# all files / ol/source/ mapquestsource.js

58.82% Statements 10/17
0% Branches 0/4
0% Functions 0/2
58.82% Lines 10/17

    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×

     goog.provide('ol.source.MapQuest');

    goog.require('goog.asserts');
    goog.require('ol.Attribution');
    goog.require('ol.source.OSM');
    goog.require('ol.source.XYZ');

    /**
     * @classdesc
     * Layer source for the MapQuest tile server.
     *
     * @constructor
     * @extends {ol.source.XYZ}
     * @param {olx.source.MapQuestOptions=} opt_options MapQuest options.
     * @api stable
     */
    ol.source.MapQuest = function(opt_options) {

      var options = opt_options || {};
      goog.asserts.assert(options.layer in ol.source.MapQuestConfig,
          'known layer configured');

      var layerConfig = ol.source.MapQuestConfig[options.layer];

      /**
       * Layer. Possible values are `osm`, `sat`, and `hyb`.
       * @type {string}
       * @private
       */
      this.layer_ = options.layer;

      var url = options.url !== undefined ? options.url :
          'https://otile{1-4}-s.mqcdn.com/tiles/1.0.0/' +
          this.layer_ + '/{z}/{x}/{y}.jpg';

      goog.base(this, {
        attributions: layerConfig.attributions,
        crossOrigin: 'anonymous',
        logo: 'https://developer.mapquest.com/content/osm/mq_logo.png',
        maxZoom: layerConfig.maxZoom,
        reprojectionErrorThreshold: options.reprojectionErrorThreshold,
        opaque: true,
        tileLoadFunction: options.tileLoadFunction,
        url: url
      });

    };
    goog.inherits(ol.source.MapQuest, ol.source.XYZ);

    /**
     * @const
     * @type {ol.Attribution}
     */
    ol.source.MapQuest.TILE_ATTRIBUTION = new ol.Attribution({
      html: 'Tiles Courtesy of <a href="http://www.mapquest.com/">MapQuest</a>'
    });

    /**
     * @type {Object.<string, {maxZoom: number, attributions: (Array.<ol.Attribution>)}>}
     */
    ol.source.MapQuestConfig = {
      'osm': {
        maxZoom: 19,
        attributions: [
          ol.source.MapQuest.TILE_ATTRIBUTION,
          ol.source.OSM.ATTRIBUTION
        ]
      },
      'sat': {
        maxZoom: 18,
        attributions: [
          ol.source.MapQuest.TILE_ATTRIBUTION,
          new ol.Attribution({
            html: 'Portions Courtesy NASA/JPL-Caltech and ' +
                'U.S. Depart. of Agriculture, Farm Service Agency'
          })
        ]
      },
      'hyb': {
        maxZoom: 18,
        attributions: [
          ol.source.MapQuest.TILE_ATTRIBUTION,
          ol.source.OSM.ATTRIBUTION
        ]
      }
    };

    /**
     * Get the layer of the source, either `osm`, `sat`, or `hyb`.
     * @return {string} Layer.
     * @api
     */
    ol.source.MapQuest.prototype.getLayer = function() {
      return this.layer_;
    };