<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    I only received one response to my question, and it was from someone
    who came up with their own patch.  I have not yet tried it myself. 
    Would love to hear from the dev team or expert programmers about
    this fix.  My original post is below, followed by the response. <br>
    <br>
    On 5/17/2012 12:20 PM, Ernie Buford wrote:
    <blockquote cite="mid:4FB5253B.5020508@uvm.edu" type="cite">Having
      fun getting started with OpenLayers, but I've hit a curious
      snag....
      <br>
      <br>
      I have a set of map tiles created using Arc2Earth, and they
      overlay nicely on Google, Yahoo, and OSM basemap data.... but no
      luck with Bing/Virtual Earth.  Is this not currently possible, or
      (more likely) am I missing some critical detail?
      <br>
      <br>
      I have modified several OL examples (e.g.,
      OL_spherical-mercator-example.html and some from the 2.10
      Beginner's Guide) by adding an XYZ layer like this:
      <br>
      <br>
          // create slope overlay layer
      <br>
          var slope = new OpenLayers.Layer.XYZ(
      <br>
              "VT Slope",
      <br>
      <a class="moz-txt-link-rfc2396E" href="http://myserver/slope/${z}/${x}/${y}.png">"http://myserver/slope/${z}/${x}/${y}.png"</a>,
      <br>
              {
      <br>
                  'opacity': 0.6, visibility: false,
      <br>
                  'isBaseLayer': false,'wrapDateLine': true
      <br>
              }
      <br>
          );
      <br>
      <br>
      At times I've added the 'sphericalMercator: true' option, but it
      does not seem to matter.
      <br>
      <br>
      I've added this exact chunk of code to several working examples. 
      The slope layer shows up over any of the aforementioned basemaps
      except Bing (which I've tried accessing via
      OpenLayers.Layer.VirtualEarth as well as directly with the newer
      OpenLayers.Layer.Bing).
      <br>
      <br>
      Why won't this work with the Bing/VE basemap?
      <br>
      <br>
      Should I be using a different method for using this type of tile
      cache as an overlay in OL?
      <br>
      <br>
      Ernie
      <br>
    </blockquote>
    <br>
    <blockquote type="cite">
      <p class="MsoNormal">Ernie,<o:p></o:p></p>
      <p class="MsoNormal"><o:p> </o:p></p>
      <p class="MsoNormal">I had the exact problem that you described -
        my XYZ overlay layer displays splendidly with a Google or OSM
        base layer, but nothing when using Bing or VirtualEarth.  I have
        a suspicion as to the cause of the problem, and have tried a
        patch that seems to correct it, but I am not an expert in the
        OpenLayers code, and cannot guarantee that my theory & fix
        are truly valid.<o:p></o:p></p>
      <p class="MsoNormal"><o:p> </o:p></p>
      <p class="MsoNormal">But here's what I have found.<o:p></o:p></p>
      <p class="MsoNormal"><o:p> </o:p></p>
      <p class="MsoNormal">I ran my test case in Internet Explorer, and
        used its "F12 developer tools" to look at the tile requests
        being sent from the browser to the XYZ tile server.  The
        important difference that I saw when using Bing instead of the
        other base layers was that the Z/zoom component of the request
        to the server was off by one with Bing relative to the other
        base layers.  So I might see a tile request with a "Z" component
        of 9 for Google or OSM, and after switching to Bing, that "Z"
        component became an 8.<o:p></o:p></p>
      <p class="MsoNormal"><o:p> </o:p></p>
      <p class="MsoNormal">Bing/VirtualEarth layers differ from many of
        the other base layers in how they designate the zoom level.  The
        other layers start with zoom level 0, while Bing starts with
        zoom level 1.  I poked around in the OpenLayers library code,
        and found that map layers can have a "zoomOffset" data member
        which I believe accounts for this difference - for Google &
        OSM, the zoomOffset is set to 0, while for Bing it is set to 1.<o:p></o:p></p>
      <p class="MsoNormal"><o:p> </o:p></p>
      <p class="MsoNormal">After some experimentation, I found a patch
        that corrected the problem for me (disclaimer: by no means does
        this mean it is an appropriate fix!).  In the
        OpenLayers.Layer.XYZ class, there is a function called 'getXYZ',
        and it includes this statement which calculates the "Z" value:<o:p></o:p></p>
      <p class="MsoNormal"><o:p> </o:p></p>
      <p class="MsoNormal">  var z = this.serverResolutions != null ?
        OpenLayers.Util.indexOf(this.serverResolutions, res) :
        this.map.getZoom() + this.zoomOffset;<o:p></o:p></p>
      <p class="MsoNormal"><o:p> </o:p></p>
      <p class="MsoNormal">Note that "this.zoomOffset" represents the
        zoomOffset value of the XYZ layer which is not displaying for
        us.  For my layer, it is set to zero, which matches the
        Google/OSM base layers, but doesn't match the Bing value.  I
        replaced that line with this code:<o:p></o:p></p>
      <p class="MsoNormal"><o:p> </o:p></p>
      <p class="MsoNormal">        var zOff;<o:p></o:p></p>
      <p class="MsoNormal">        if (this.map.baseLayer.zoomOffset) {<o:p></o:p></p>
      <p class="MsoNormal">            zOff =
        this.map.baseLayer.zoomOffset;<o:p></o:p></p>
      <p class="MsoNormal">        } else {<o:p></o:p></p>
      <p class="MsoNormal">            zOff = this.zoomOffset;<o:p></o:p></p>
      <p class="MsoNormal">        }<o:p></o:p></p>
      <p class="MsoNormal">        var z = this.serverResolutions !=
        null ? OpenLayers.Util.indexOf(this.serverResolutions, res) :
        this.map.getZoom() + zOff;<o:p></o:p></p>
      <p class="MsoNormal"><o:p> </o:p></p>
      <p class="MsoNormal">The replacement code checks the zoomOffset
        value of the base map layer (if it exists) and uses it if it's
        present; otherwise, it uses the zoomOffset of the overlay
        layer.  With this code in place, I find that my overlay layer
        now displays properly for all my base map layers.<o:p></o:p></p>
      <p class="MsoNormal"><o:p> </o:p></p>
      Again, I make no guarantees about the validity of this change, and
      would like to have someone on the OpenLayers development team
      review it.</blockquote>
    <br>
  </body>
</html>