[OpenLayers-Commits] r11059 - in trunk/openlayers:
lib/OpenLayers/Layer tests/Layer
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Mon Jan 24 16:45:44 EST 2011
Author: ahocevar
Date: 2011-01-24 13:45:44 -0800 (Mon, 24 Jan 2011)
New Revision: 11059
Modified:
trunk/openlayers/lib/OpenLayers/Layer/Bing.js
trunk/openlayers/tests/Layer/Bing.html
Log:
using new restricedMinZoom property to make Layer.Bing code much cleaner. r=bartvde (closes #3025)
Modified: trunk/openlayers/lib/OpenLayers/Layer/Bing.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/Bing.js 2011-01-24 21:43:35 UTC (rev 11058)
+++ trunk/openlayers/lib/OpenLayers/Layer/Bing.js 2011-01-24 21:45:44 UTC (rev 11059)
@@ -77,8 +77,7 @@
*/
initialize: function(options) {
options = OpenLayers.Util.applyDefaults({
- zoomOffset: 1,
- maxResolution: 78271.51695,
+ restrictedMinZoom: 1,
sphericalMercator: true
}, options)
var name = options.name || "Bing " + (options.type || this.type);
@@ -124,20 +123,11 @@
for (var i=0; i<res.imageUrlSubdomains.length; ++i) {
this.url.push(url.replace("{subdomain}", res.imageUrlSubdomains[i]));
};
- var resolution;
- if (this.map && this.map.baseLayer === this && this.map.getCenter()) {
- // if we are the current base layer and the map was centered
- // already, we need to remember the current resolution to find a
- // matching zoom level after the maxResolution changes
- resolution = this.getResolution();
- }
this.addOptions({
- maxResolution: 78271.51695 / Math.pow(2, res.zoomMin - 1),
- numZoomLevels: res.zoomMax - res.zoomMin + 1
+ restrictedMinZoom: res.zoomMin,
+ numZoomLevels: res.zoomMax + 1
});
- // adjust zoom level to match the previous resolution - this triggers a
- // moveTo on all layers.
- resolution && this.map.zoomTo(this.getZoomForResolution(resolution));
+ this.updateAttribution();
// redraw to replace "blank.gif" tiles with real tiles
this.redraw();
},
@@ -179,7 +169,7 @@
*/
updateAttribution: function() {
var metadata = this.metadata;
- if (!metadata || !this.map) {
+ if (!metadata || !this.map || !this.map.center) {
return;
}
var res = metadata.resourceSets[0].resources[0];
@@ -213,9 +203,7 @@
*/
setMap: function() {
OpenLayers.Layer.XYZ.prototype.setMap.apply(this, arguments);
- if (this.map.getCenter()) {
- this.updateAttribution();
- }
+ this.updateAttribution();
this.map.events.register("moveend", this, this.updateAttribution);
},
Modified: trunk/openlayers/tests/Layer/Bing.html
===================================================================
--- trunk/openlayers/tests/Layer/Bing.html 2011-01-24 21:43:35 UTC (rev 11058)
+++ trunk/openlayers/tests/Layer/Bing.html 2011-01-24 21:45:44 UTC (rev 11059)
@@ -24,7 +24,7 @@
};
layer = new OpenLayers.Layer.Bing({metadataParams: {foo: "bar"}});
t.ok(layer instanceof OpenLayers.Layer.Bing, "returns OpenLayers.Layer.Bing object" );
- t.delay_call(2, function() {
+ t.delay_call(5, function() {
t.eq(log.length, 1, "processMetadata called");
t.eq(OpenLayers.Util.getParameters(log[0]).foo, "bar", "metadataParams passed to url correctly.");
OpenLayers.Layer.Bing.processMetadata = origProcessMetadata;
@@ -66,13 +66,13 @@
})]);
map2.zoomToMaxExtent();
- t.delay_call(2.0, function() {
+ t.delay_call(5, function() {
origProcessMetadata.call(layer, meta[0]);
t.eq(extent.toBBOX(), map.getExtent().toBBOX(), "layer extent correct for base layer with zoomMin == 1.");
map.destroy();
});
- t.delay_call(2.5, function() {
+ t.delay_call(6, function() {
origProcessMetadata.call(layer2, meta[1]);
t.eq(extent2.toBBOX(), map2.getExtent().toBBOX(), "layer extent correct for base layer with zoomMin == 2.");
map2.destroy();
More information about the Commits
mailing list