fix Bing layer's zoom level management. r=tschaub (closes #2987)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@10997 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2011-01-03 18:18:43 +00:00
parent 06b32c30a7
commit d0ab1fd219
2 changed files with 71 additions and 44 deletions

View File

@@ -18,35 +18,6 @@
*/
OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, {
/**
* Constant: RESOLUTIONS
*/
RESOLUTIONS: [
78271.517,
39135.7585,
19567.87925,
9783.939625,
4891.9698125,
2445.98490625,
1222.992453125,
611.4962265625,
305.74811328125,
152.874056640625,
76.4370283203125,
38.21851416015625,
19.109257080078127,
9.554628540039063,
4.777314270019532,
2.388657135009766,
1.194328567504883,
0.5971642837524415,
0.29858214187622073,
0.14929107093811037,
0.07464553546905518,
0.03732276773452759,
0.018661383867263796
],
/**
* Property: attributionTemplate
* {String}
@@ -58,12 +29,6 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, {
'href="http://www.microsoft.com/maps/product/terms.html">' +
'Terms of Use</a></span>',
/**
* Property: sphericalMercator
* {Boolean} always true for this layer type
*/
sphericalMercator: true,
/**
* Property: metadata
* {Object} Metadata for this layer, as returned by the callback script
@@ -131,7 +96,14 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, {
OpenLayers.Layer.Bing.prototype.EVENT_TYPES.concat(
OpenLayers.Layer.prototype.EVENT_TYPES
);
options = OpenLayers.Util.applyDefaults({
zoomOffset: 1,
maxResolution: 78271.51695,
sphericalMercator: true
}, options)
var name = options.name || "Bing " + (options.type || this.type);
var newArgs = [name, null, options];
OpenLayers.Layer.XYZ.prototype.initialize.apply(this, newArgs);
this.loadMetadata(this.type);
@@ -172,15 +144,22 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, {
for (var i=0; i<res.imageUrlSubdomains.length; ++i) {
this.url.push(url.replace("{subdomain}", res.imageUrlSubdomains[i]));
};
this.addOptions({
resolutions: this.RESOLUTIONS.slice(res.zoomMin-1, res.zoomMax-1),
zoomOffset: res.zoomMin
});
if (this.map) {
this.redraw();
this.updateAttribution();
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
});
// adjust zoom level to match the previous resolution - this triggers a
// moveTo on all layers.
resolution && this.map.zoomTo(this.getZoomForResolution(resolution));
// redraw to replace "blank.gif" tiles with real tiles
this.redraw();
},
/**