var map = new OpenLayers.Map("Map", { maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34), numZoomLevels:18, maxResolution:156543.0339, units:'m', projection: "EPSG:900913", displayProjection: new OpenLayers.Projection("EPSG:4326") }); var layer = new OpenLayers.Layer.TMS("Archive.org Tiles", ["http://www.archive.org/download/SharedMapTiles"], { type: 'png', getURL: getArchiveTileURL, displayOutsideMaxExtent: true, attribution: '(C) CC-by-SA FOSM.org', transitionEffect: 'resize'}); var control = new OpenLayers.Control(); OpenLayers.Util.extend(control, { draw: function () { // this Handler.Box will intercept the shift-mousedown // before Control.MouseDefault gets to see it this.box = new OpenLayers.Handler.Box( control, {"done": this.notice}, {keyMask: OpenLayers.Handler.MOD_SHIFT}); this.box.activate(); }, notice: function (bounds) { var ul = map.getLonLatFromPixel(new OpenLayers.Pixel(bounds.left, bounds.top)); var br = map.getLonLatFromPixel(new OpenLayers.Pixel(bounds.right, bounds.bottom)); ul.transform(new OpenLayers.Projection("EPSG:900913"), new OpenLayers.Projection("EPSG:4326")); br.transform(new OpenLayers.Projection("EPSG:900913"), new OpenLayers.Projection("EPSG:4326")); alert("render_range(10, 16, "+ ul.lat.toFixed(4) + ", " + ul.lon.toFixed(4) + ", " + br.lat.toFixed(4) + ", " + br.lon.toFixed(4) + ");"); } }); map.addLayer(layer); map.addControl(control); map.setCenter(lonLatToMercator(new OpenLayers.LonLat(lng, lat)), zoom); OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3; OpenLayers.Util.onImageLoadError = function() { this.src = "404.png"; } map.addControl(new OpenLayers.Control.Attribution());