diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js index 158301174a..8168012caa 100644 --- a/lib/OpenLayers/Layer.js +++ b/lib/OpenLayers/Layer.js @@ -275,16 +275,6 @@ OpenLayers.Layer = OpenLayers.Class({ * {Float} */ minResolution: null, - - /** - * Property: resolution - * {Float} Current resolution that the layer is drawn in. This is - * used to determine whether the zoom has changed when calling - * from . Subclasses may set this.resolution to - * null prior to calling redraw to force passing zoomChanged - * true to moveTo. - */ - resolution: null, /** * APIProperty: numZoomLevels @@ -566,8 +556,7 @@ OpenLayers.Layer = OpenLayers.Class({ var extent = this.getExtent(); if (extent && this.inRange && this.visibility) { - var zoomChanged = this.resolution == null || - this.resolution !== this.map.getResolution(); + var zoomChanged = true; this.moveTo(extent, zoomChanged, false); this.events.triggerEvent("moveend", {"zoomChanged": zoomChanged}); @@ -592,7 +581,6 @@ OpenLayers.Layer = OpenLayers.Class({ display = display && this.inRange; } this.display(display); - this.resolution = this.map.getResolution(); }, /** @@ -648,8 +636,6 @@ OpenLayers.Layer = OpenLayers.Class({ // deal with gutters this.setTileSize(); - - this.resolution = null; } }, @@ -889,16 +875,6 @@ OpenLayers.Layer = OpenLayers.Class({ props.resolutions = this.resolutionsFromScales(props.scales); } if(props.resolutions == null) { - var maxExtent = this.maxExtent; - if (!props.maxResolution && maxExtent) { - // maxResolution for default grid sets assumes that at zoom - // level zero, the whole world fits on one tile. - var tileSize = this.tileSize || this.map.getTileSize(); - props.maxResolution = Math.max( - maxExtent.getWidth() / tileSize.w, - maxExtent.getHeight() / tileSize.h - ); - } props.resolutions = this.calculateResolutions(props); } } @@ -1034,6 +1010,18 @@ OpenLayers.Layer = OpenLayers.Class({ minResolution = Math.max(wRes, hRes); } + if(typeof maxResolution !== "number" && + typeof minResolution !== "number" && + this.maxExtent != null) { + // maxResolution for default grid sets assumes that at zoom + // level zero, the whole world fits on one tile. + var tileSize = this.tileSize || this.map.getTileSize(); + maxResolution = Math.max( + this.maxExtent.getWidth() / tileSize.w, + this.maxExtent.getHeight() / tileSize.h + ); + } + // determine numZoomLevels var maxZoomLevel = props.maxZoomLevel; var numZoomLevels = props.numZoomLevels; diff --git a/lib/OpenLayers/Layer/Bing.js b/lib/OpenLayers/Layer/Bing.js index 162edf98a5..f6b0259b57 100644 --- a/lib/OpenLayers/Layer/Bing.js +++ b/lib/OpenLayers/Layer/Bing.js @@ -232,7 +232,8 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, { this.map.getProjectionObject(), new OpenLayers.Projection("EPSG:4326") ); - var providers = res.imageryProviders, zoom = this.map.getZoom() + 1, + var providers = res.imageryProviders, + zoom = this.serverResolutions.indexOf(this.getServerResolution()), copyrights = "", provider, i, ii, j, jj, bbox, coverage; for (i=0,ii=providers.length; i diff --git a/tests/Tile/Image.html b/tests/Tile/Image.html index 545a6d2826..6ef426e386 100644 --- a/tests/Tile/Image.html +++ b/tests/Tile/Image.html @@ -374,53 +374,6 @@ map.destroy(); } - // test for https://github.com/openlayers/openlayers/pull/36 - // (more an integration test than a unit test) - function test_olImageLoadError(t) { - t.plan(6); - - var map = new OpenLayers.Map('map'); - var layer = new OpenLayers.Layer.WMS("invalid", "foo", {layers: 'basic'}); - map.addLayer(layer); - - var size = new OpenLayers.Size(5, 6); - var position = new OpenLayers.Pixel(20, 30); - var bounds = new OpenLayers.Bounds(1, 2, 3, 4); - - var tile = new OpenLayers.Tile.Image(layer, position, bounds, null, size); - var log = []; - tile.events.register("loaderror", this, function(e) { - log.push([ - e.object.imgDiv.style.visibility, - OpenLayers.Element.hasClass(e.object.imgDiv, 'olImageLoadError') - ]); - }); - tile.events.register("loadend", this, function(e) { - log.push(e); - }) - tile.draw(); - - t.delay_call(0.1, function() { - - t.eq(log.length, 2, "loaderror and loadend events triggered"); - t.eq(log[0][0], "hidden", "tile still hidden when loaderror is triggered"); - t.eq(log[0][1], true, "tile has olImageLoadError class already when loaderror is triggered"); - t.ok(log[1].object === tile, "loadend event triggered after loaderror"); - - // check initial state - t.ok(OpenLayers.Element.hasClass(tile.imgDiv, 'olImageLoadError'), - 'tile image has the olImageLoadError class (init state)'); - - layer.setVisibility(false); - layer.setVisibility(true); - - t.ok(OpenLayers.Element.hasClass(tile.imgDiv, 'olImageLoadError'), - 'tile image still has the olImageLoadError class'); - - map.destroy(); - }); - } - function test_getCanvasContext(t) { if (!OpenLayers.CANVAS_SUPPORTED) { t.plan(0); @@ -445,7 +398,7 @@ }); } } - +