Merge branch '2.12'
This commit is contained in:
+13
-25
@@ -276,16 +276,6 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
*/
|
*/
|
||||||
minResolution: null,
|
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
|
|
||||||
* <moveTo> from <redraw>. Subclasses may set this.resolution to
|
|
||||||
* null prior to calling redraw to force passing zoomChanged
|
|
||||||
* true to moveTo.
|
|
||||||
*/
|
|
||||||
resolution: null,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: numZoomLevels
|
* APIProperty: numZoomLevels
|
||||||
* {Integer}
|
* {Integer}
|
||||||
@@ -566,8 +556,7 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
var extent = this.getExtent();
|
var extent = this.getExtent();
|
||||||
|
|
||||||
if (extent && this.inRange && this.visibility) {
|
if (extent && this.inRange && this.visibility) {
|
||||||
var zoomChanged = this.resolution == null ||
|
var zoomChanged = true;
|
||||||
this.resolution !== this.map.getResolution();
|
|
||||||
this.moveTo(extent, zoomChanged, false);
|
this.moveTo(extent, zoomChanged, false);
|
||||||
this.events.triggerEvent("moveend",
|
this.events.triggerEvent("moveend",
|
||||||
{"zoomChanged": zoomChanged});
|
{"zoomChanged": zoomChanged});
|
||||||
@@ -592,7 +581,6 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
display = display && this.inRange;
|
display = display && this.inRange;
|
||||||
}
|
}
|
||||||
this.display(display);
|
this.display(display);
|
||||||
this.resolution = this.map.getResolution();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -648,8 +636,6 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
|
|
||||||
// deal with gutters
|
// deal with gutters
|
||||||
this.setTileSize();
|
this.setTileSize();
|
||||||
|
|
||||||
this.resolution = null;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -889,16 +875,6 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
props.resolutions = this.resolutionsFromScales(props.scales);
|
props.resolutions = this.resolutionsFromScales(props.scales);
|
||||||
}
|
}
|
||||||
if(props.resolutions == null) {
|
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);
|
props.resolutions = this.calculateResolutions(props);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1034,6 +1010,18 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
minResolution = Math.max(wRes, hRes);
|
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
|
// determine numZoomLevels
|
||||||
var maxZoomLevel = props.maxZoomLevel;
|
var maxZoomLevel = props.maxZoomLevel;
|
||||||
var numZoomLevels = props.numZoomLevels;
|
var numZoomLevels = props.numZoomLevels;
|
||||||
|
|||||||
@@ -232,7 +232,8 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, {
|
|||||||
this.map.getProjectionObject(),
|
this.map.getProjectionObject(),
|
||||||
new OpenLayers.Projection("EPSG:4326")
|
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;
|
copyrights = "", provider, i, ii, j, jj, bbox, coverage;
|
||||||
for (i=0,ii=providers.length; i<ii; ++i) {
|
for (i=0,ii=providers.length; i<ii; ++i) {
|
||||||
provider = providers[i];
|
provider = providers[i];
|
||||||
|
|||||||
@@ -122,7 +122,6 @@ OpenLayers.Layer.HTTPRequest = OpenLayers.Class(OpenLayers.Layer, {
|
|||||||
*/
|
*/
|
||||||
mergeNewParams:function(newParams) {
|
mergeNewParams:function(newParams) {
|
||||||
this.params = OpenLayers.Util.extend(this.params, newParams);
|
this.params = OpenLayers.Util.extend(this.params, newParams);
|
||||||
this.resolution = null;
|
|
||||||
var ret = this.redraw();
|
var ret = this.redraw();
|
||||||
if(this.map != null) {
|
if(this.map != null) {
|
||||||
this.map.events.triggerEvent("changelayer", {
|
this.map.events.triggerEvent("changelayer", {
|
||||||
@@ -147,7 +146,7 @@ OpenLayers.Layer.HTTPRequest = OpenLayers.Class(OpenLayers.Layer, {
|
|||||||
if (force) {
|
if (force) {
|
||||||
return this.mergeNewParams({"_olSalt": Math.random()});
|
return this.mergeNewParams({"_olSalt": Math.random()});
|
||||||
} else {
|
} else {
|
||||||
return OpenLayers.Layer.prototype.redraw.call(this);
|
return OpenLayers.Layer.prototype.redraw.apply(this, []);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -520,20 +520,6 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* APIMethod: redraw
|
|
||||||
* Redraws the layer. Returns true if the layer was redrawn, false if not.
|
|
||||||
*
|
|
||||||
* Returns:
|
|
||||||
* {Boolean} The layer was redrawn.
|
|
||||||
*/
|
|
||||||
redraw: function() {
|
|
||||||
// this is to force Layer.redraw set zoomChanged
|
|
||||||
// to true in the moveTo call
|
|
||||||
this.resolution = null;
|
|
||||||
return OpenLayers.Layer.prototype.redraw.apply(this, arguments);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: display
|
* APIMethod: display
|
||||||
* Hide or show the Layer
|
* Hide or show the Layer
|
||||||
|
|||||||
+8
-68
@@ -408,6 +408,9 @@
|
|||||||
"1.20", null, {maxScale: 100000, numZoomLevels: 3, units: "m"},
|
"1.20", null, {maxScale: 100000, numZoomLevels: 3, units: "m"},
|
||||||
[141.11103491115225, 70.55551745557612, 35.27775872778806], 35.27775872778806, 141.11103491115225
|
[141.11103491115225, 70.55551745557612, 35.27775872778806], 35.27775872778806, 141.11103491115225
|
||||||
], [
|
], [
|
||||||
|
"1.21", null, {numZoomLevels: 2}, // maxResolution calculated based on the projection's maxExtent here
|
||||||
|
[1.40625, 0.703125], 0.703125, 1.40625
|
||||||
|
], [
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Batch 2: custom map options map and sensible layer options
|
* Batch 2: custom map options map and sensible layer options
|
||||||
@@ -551,8 +554,8 @@
|
|||||||
/*
|
/*
|
||||||
* Batch 2.8: numZoomLevels set in the layer options
|
* Batch 2.8: numZoomLevels set in the layer options
|
||||||
*/
|
*/
|
||||||
"2.8.0", {maxResolution: 80}, {numZoomLevels: 4},
|
"2.8.0", {maxResolution: 80}, {numZoomLevels: 4}, // maxResolution calculated based on the projection's maxExtent here
|
||||||
[80, 40, 20, 10], 10, 80
|
[1.40625, 0.703125, 0.3515625, 0.17578125], 0.17578125, 1.40625
|
||||||
], [
|
], [
|
||||||
"2.8.1", {maxResolution: 80, numZoomLevels: 4}, {numZoomLevels: null},
|
"2.8.1", {maxResolution: 80, numZoomLevels: 4}, {numZoomLevels: null},
|
||||||
[80, 40, 20, 10], 10, 80
|
[80, 40, 20, 10], 10, 80
|
||||||
@@ -682,83 +685,20 @@
|
|||||||
// test that the moveend event was triggered
|
// test that the moveend event was triggered
|
||||||
t.ok(log.event, "an event was logged");
|
t.ok(log.event, "an event was logged");
|
||||||
t.eq(log.event.type, "moveend", "moveend was triggered");
|
t.eq(log.event.type, "moveend", "moveend was triggered");
|
||||||
t.eq(log.event.zoomChanged, false, "event says zoomChanged false");
|
t.eq(log.event.zoomChanged, true, "event says zoomChanged true - poor name");
|
||||||
|
|
||||||
layer.moveTo = function(bounds, zoomChanged, dragging) {
|
layer.moveTo = function(bounds, zoomChanged, dragging) {
|
||||||
var extent = layer.map.getExtent();
|
var extent = layer.map.getExtent();
|
||||||
t.ok(bounds.equals(extent),
|
t.ok(bounds.equals(extent),
|
||||||
"redraw calls moveTo with the map extent");
|
"redraw calls moveTo with the map extent");
|
||||||
t.ok(!zoomChanged,
|
t.ok(zoomChanged,
|
||||||
"redraw calls moveTo with zoomChanged false");
|
"redraw calls moveTo with zoomChanged true");
|
||||||
t.ok(!dragging,
|
t.ok(!dragging,
|
||||||
"redraw calls moveTo with dragging false");
|
"redraw calls moveTo with dragging false");
|
||||||
}
|
}
|
||||||
layer.redraw();
|
layer.redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function includes integration tests to verify that the
|
|
||||||
// layer's moveTo function is called with the expected value
|
|
||||||
// for zoomChanged
|
|
||||||
function test_moveTo_zoomChanged(t) {
|
|
||||||
t.plan(6);
|
|
||||||
|
|
||||||
var log = {};
|
|
||||||
var map = new OpenLayers.Map('map');
|
|
||||||
|
|
||||||
var l1 = new OpenLayers.Layer('l1', {isBaseLayer: true});
|
|
||||||
l1.moveTo = function(bounds, zoomChanged, dragging) {
|
|
||||||
log.moveTo = {zoomChanged: zoomChanged};
|
|
||||||
OpenLayers.Layer.prototype.moveTo.apply(this, arguments);
|
|
||||||
};
|
|
||||||
|
|
||||||
map.addLayer(l1);
|
|
||||||
map.zoomToMaxExtent();
|
|
||||||
|
|
||||||
log = {};
|
|
||||||
l1.redraw();
|
|
||||||
t.eq(log.moveTo.zoomChanged, false,
|
|
||||||
"[a] redraw calls moveTo with zoomChanged false");
|
|
||||||
|
|
||||||
log = {};
|
|
||||||
l1.resolution = null;
|
|
||||||
l1.redraw();
|
|
||||||
t.eq(log.moveTo.zoomChanged, true,
|
|
||||||
"[b] redraw calls moveTo with zoomChanged true");
|
|
||||||
|
|
||||||
l1.setVisibility(false);
|
|
||||||
log = {};
|
|
||||||
l1.setVisibility(true);
|
|
||||||
t.eq(log.moveTo.zoomChanged, false,
|
|
||||||
"[c] redraw calls moveTo with zoomChanged false");
|
|
||||||
|
|
||||||
l1.setVisibility(false);
|
|
||||||
map.zoomIn();
|
|
||||||
log = {};
|
|
||||||
l1.setVisibility(true);
|
|
||||||
t.eq(log.moveTo.zoomChanged, true,
|
|
||||||
"[d] redraw calls moveTo with zoomChanged true");
|
|
||||||
|
|
||||||
l1.moveTo = OpenLayers.Layer.prototype.moveTo;
|
|
||||||
|
|
||||||
var l2 = new OpenLayers.Layer('l2');
|
|
||||||
l2.moveTo = function(bounds, zoomChanged, dragging) {
|
|
||||||
log.moveTo = {zoomChanged: zoomChanged};
|
|
||||||
OpenLayers.Layer.prototype.moveTo.apply(this, arguments);
|
|
||||||
};
|
|
||||||
log = {};
|
|
||||||
map.addLayer(l2);
|
|
||||||
t.eq(log.moveTo.zoomChanged, true,
|
|
||||||
"[e] redraw calls moveTo with zoomChanged true");
|
|
||||||
|
|
||||||
map.removeLayer(l2);
|
|
||||||
log = {};
|
|
||||||
map.addLayer(l2);
|
|
||||||
t.eq(log.moveTo.zoomChanged, true,
|
|
||||||
"[f] redraw calls moveTo with zoomChanged true");
|
|
||||||
|
|
||||||
map.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
function test_layer_setIsBaseLayer(t) {
|
function test_layer_setIsBaseLayer(t) {
|
||||||
t.plan(2);
|
t.plan(2);
|
||||||
var map = new OpenLayers.Map('map');
|
var map = new OpenLayers.Map('map');
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_Layer_HTTPRequest_mergeNewParams (t) {
|
function test_Layer_HTTPRequest_mergeNewParams (t) {
|
||||||
t.plan( 9 );
|
t.plan( 8 );
|
||||||
|
|
||||||
var map = new OpenLayers.Map('map');
|
var map = new OpenLayers.Map('map');
|
||||||
layer = new OpenLayers.Layer.HTTPRequest(name, url, params, options);
|
layer = new OpenLayers.Layer.HTTPRequest(name, url, params, options);
|
||||||
@@ -100,9 +100,7 @@
|
|||||||
|
|
||||||
layer.redraw = function() {
|
layer.redraw = function() {
|
||||||
t.ok(true, "layer.mergeNewParams calls layer.redraw");
|
t.ok(true, "layer.mergeNewParams calls layer.redraw");
|
||||||
t.ok(layer.resolution === null, "layer.mergeNewParams sets resolution to null");
|
}
|
||||||
};
|
|
||||||
layer.resolution = 'fake';
|
|
||||||
layer.mergeNewParams();
|
layer.mergeNewParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -869,32 +869,7 @@
|
|||||||
"featuresadded event received expected number of features");
|
"featuresadded event received expected number of features");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_redraw(t) {
|
|
||||||
t.plan(2);
|
|
||||||
|
|
||||||
// test that when redraw is called on a vector layer then
|
|
||||||
// moveTo gets called on the layer and receives zoomChanged
|
|
||||||
// true
|
|
||||||
|
|
||||||
var log = [];
|
|
||||||
|
|
||||||
var map = new OpenLayers.Map("map");
|
|
||||||
var layer = new OpenLayers.Layer.Vector("vector", {isBaseLayer: true});
|
|
||||||
map.addLayer(layer);
|
|
||||||
map.setCenter([0, 0], 5);
|
|
||||||
|
|
||||||
layer.moveTo = function(extent, zoomChanged) {
|
|
||||||
log.push(zoomChanged);
|
|
||||||
};
|
|
||||||
|
|
||||||
layer.redraw();
|
|
||||||
t.eq(log.length, 1, "redraw makes moveTo be called once");
|
|
||||||
if (log.length == 1) {
|
|
||||||
t.eq(log[0], true, "redraw makes moveTo be called with zoomChanged true");
|
|
||||||
}
|
|
||||||
|
|
||||||
map.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -374,53 +374,6 @@
|
|||||||
map.destroy();
|
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) {
|
function test_getCanvasContext(t) {
|
||||||
if (!OpenLayers.CANVAS_SUPPORTED) {
|
if (!OpenLayers.CANVAS_SUPPORTED) {
|
||||||
t.plan(0);
|
t.plan(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user