title: Use Bing Quadkey tiles instead of x/y/z tiles in leafletjs map
body: <p>I try to create a map with leaflet.js where it is possible to switch between different tile layers. It works great with tileservers that serve the tiles with the standard x,y and z(oom) schema. However, Microsoft Bing uses its own quadkey schema. I found a JavaScript function to convert xyz to quad, but I don't know how to use it. Please see my example:</p>
  
  <pre><code>function toQuad(x, y, z) {
      var quadkey = '';
      for ( var i = z; i &gt;= 0; --i) {
          var bitmask = 1 &lt;&lt; i;
          var digit = 0;
          if ((x &amp; bitmask) !== 0) {
              digit |= 1;}
          if ((y &amp; bitmask) !== 0) {
              digit |= 2;}
          quadkey += digit;
      }
      return quadkey;
  };
  var openstreetmap = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{attribution: '&amp;copy; &lt;a href="http://osm.org/copyright"&gt;OpenStreetMap&lt;/a&gt; contributors'}),
  arcgissat  = L.tileLayer('http://{s}.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {subdomains: ['server', 'services'], attribution: '&amp;copy; &lt;a href="http://www.arcgis.com/"&gt;ArcGIS esri&lt;/a&gt;'})
  //   bingsat  = L.tileLayer('http://t{s}.tiles.virtualearth.net/tiles/a'+toQuad({x},{y},{z})+'.jpeg?g=1398', {subdomains: [0,1,2,3,4,5], attribution: '&amp;copy; &lt;a href="http://bing.com/maps"&gt;Bing Maps&lt;/a&gt;'}),
  var map = L.map('map', {
      center: [48.85,2.33],
      zoom: 10,
      layers: [openstreetmap]
  });
  var baseLayers = {
      "OpenStreetMap": openstreetmap,
  //      "Bing Sat": bingsat,
              "ArcGIS esri Sat": arcgissat
  };
  L.control.layers(baseLayers, null, {collapsed: false}).addTo(map);
  </code></pre>
  
  <p>Basically I just don't know how to call the JavaScript function inside of the variable declaration with the {x}, {y} and {z} values that leafletjs provides.</p>