code: function() {
          var res = this.metadata.resourceSets[0].resources[0];
          var url = res.imageUrl.replace("{quadkey}", "${quadkey}");
          url = url.replace("{culture}", this.culture);
          url = url.replace(this.protocolRegex, this.protocol);
          this.url = [];
          for (var i=0; i<res.imageUrlSubdomains.length; ++i) {
              this.url.push(url.replace("{subdomain}", res.imageUrlSubdomains[i]));
          }
          this.addOptions({
              maxResolution: Math.min(
                  this.serverResolutions[res.zoomMin],
                  this.maxResolution || Number.POSITIVE_INFINITY
              ),
              numZoomLevels: Math.min(
                  res.zoomMax + 1 - res.zoomMin, this.numZoomLevels
              )
          }, true);
          if (!this.isBaseLayer) {
              this.redraw();
          }
          this.updateAttribution();
      }
docs: Method: initLayer
  
  Sets layer properties according to the metadata provided by the API