<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>OpenLayers Zoom bug</title>
  <script src="http://maps.google.com/maps/api/js?v=3.6&sensor=false"></script>
    <script type="text/javascript" src="OpenLayers-2.11/OpenLayers.js"></script>
    <script type="text/javascript">
        var map, scaleOut;
 function updateScale() {
    var scale;
    var units = this.map.getUnits();
    if(!units) {
          return;
    }
    var inches = OpenLayers.INCHES_PER_UNIT;
    scale = (map.getGeodesicPixelSize().w || 0.000001) *
                inches["km"] * OpenLayers.DOTS_PER_INCH;

    if (!scale) {
        return;
    }

    if (scale >= 9500 && scale <= 950000) {
        scale = Math.round(scale / 1000) + "K";
    } else if (scale >= 950000) {
        scale = Math.round(scale / 1000000) + "M";
    } else {
        scale = Math.round(scale);
    }

    scaleOut = '<b>Scale = 1:' + scale + '</b>';
}

        function init() {
                         var p4326 = new OpenLayers.Projection("EPSG:4326");
                        var p900913 = new OpenLayers.Projection("EPSG:900913");
                        fullBounds = new OpenLayers.Bounds(161.0,-50.0,179.99,-31.0);
                    fullBounds.transform(p4326,p900913);
                    proj = p900913;
                    dproj = p4326;
                    projstr = "EPSG:900913";
                        var options = {
                                projection: proj,
                                displayProjection: dproj,
                                units: "m",
                                numZoomLevels: 18,
                                maxResolution: 156543.0339,
                                maxExtent: fullBounds
                        };
            map = new OpenLayers.Map("map",options);
    map.removeControl(map.controls[1]);
    map.addControl(new OpenLayers.Control.PanZoomBar());
    map.addControl(new OpenLayers.Control.Attribution());
    map.events.register( 'moveend', this, updateScale);
    selectedLayer = new OpenLayers.Layer.Vector("Selected Layer", {
        wrapDateLine: true,
        displayOutsideMaxExtent: true,
        displayInLayerSwitcher: false,
    });
      map.addLayer(selectedLayer);

             pySelCtrl = new OpenLayers.Control.DrawFeature(selectedLayer, OpenLayers.Handler.Polygon, {
                    geodesic: true,
                    handlerOptions: {
                        citeCompliant: true
                    }
            });
    map.addControl(pySelCtrl);
    pySelCtrl.activate();

            var gphy = new OpenLayers.Layer.Google(
                "Google Physical",
                {type: google.maps.MapTypeId.TERRAIN ,sphericalMercator: true, numZoomLevels:20, wrapDateLine:true}
            );

                        var seislay = new OpenLayers.Layer.WMS("seismic","http://maps.gns.cri.nz/geoserver/wms",
                                                        {layers:"PETROLEUM.NZ_2D_SEIS_LINES",srs:projstr,transparent: true},{isBaseLayer: false, displayLegend:true}
                                                        );
            map.addLayers([gphy,seislay]);
                        map.addControl(new OpenLayers.Control.MousePosition({
                            formatOutput: function(lonLat) {
                        var digits = parseInt(this.numDigits);
                        var newHtml =
                                    this.prefix +
                                    lonLat.lat.toFixed(digits) +
                                    this.separator +
                                    lonLat.lon.toFixed(digits) +
                                    this.suffix + '<BR>' + scaleOut;
                        return newHtml;
                     }
                    }));
                        map.zoomToExtent(fullBounds);

        }
    </script>
  </head>
  <body onload="init()">
    <h1 id="title">180 deg problem</h1>

    <div id="tags"></div>


    <div id="map" class="smallmap"></div>

  </body>
</html>