Merge pull request #998 from bartvde/tilemgrdefault
enable TileManager by default as suggested by @marcjansen and @bartvde ... (r=@ahocevar)
This commit is contained in:
@@ -29,7 +29,6 @@ OpenLayers/Protocol/HTTP.js
|
||||
OpenLayers/Protocol/WFS.js
|
||||
OpenLayers/Protocol/WFS/v1_0_0.js
|
||||
OpenLayers/Strategy/Fixed.js
|
||||
OpenLayers/TileManager.js
|
||||
|
||||
[exclude]
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
var map = new OpenLayers.Map({
|
||||
div: "map",
|
||||
tileManager: new OpenLayers.TileManager(),
|
||||
layers: [
|
||||
new OpenLayers.Layer.OSM("OSM (without buffer)"),
|
||||
new OpenLayers.Layer.OSM("OSM (with buffer)", null, {buffer: 2})
|
||||
|
||||
@@ -42,7 +42,6 @@ var init = function (onSelectFeatureFunction) {
|
||||
theme: null,
|
||||
projection: sm,
|
||||
numZoomLevels: 18,
|
||||
tileManager: new OpenLayers.TileManager(),
|
||||
controls: [
|
||||
new OpenLayers.Control.Attribution(),
|
||||
new OpenLayers.Control.TouchNavigation({
|
||||
|
||||
@@ -102,7 +102,6 @@ var map;
|
||||
units: "m",
|
||||
maxResolution: 38.21851413574219,
|
||||
numZoomLevels: 8,
|
||||
tileManager: new OpenLayers.TileManager(),
|
||||
controls: [
|
||||
new OpenLayers.Control.Navigation(),
|
||||
new OpenLayers.Control.Attribution(),
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
* @requires OpenLayers/Events.js
|
||||
* @requires OpenLayers/Tween.js
|
||||
* @requires OpenLayers/Projection.js
|
||||
* @requires OpenLayers/TileManager.js
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -372,15 +373,15 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
* property at the time the control is added to the map.
|
||||
*/
|
||||
displayProjection: null,
|
||||
|
||||
|
||||
/**
|
||||
* APIProperty: tileManager
|
||||
* {<OpenLayers.TileManager>} If configured at construction time, the map
|
||||
* will use the TileManager to queue image requests and to cache tile image
|
||||
* elements. Note: make sure that OpenLayers/TileManager.js is included in
|
||||
* your build profile.
|
||||
* {<OpenLayers.TileManager>|Object} By default the map will use the TileManager
|
||||
* to queue image requests and to cache tile image elements. To create a
|
||||
* map without a TileManager configure the map with tileManager: null.
|
||||
* To create a TileManager with non-default options, supply the options
|
||||
* instead or alternatively supply an instance of {<OpenLayers.TileManager>}.
|
||||
*/
|
||||
tileManager: null,
|
||||
|
||||
/**
|
||||
* APIProperty: fallThrough
|
||||
@@ -613,7 +614,10 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
{includeXY: true}
|
||||
);
|
||||
|
||||
if (this.tileManager) {
|
||||
if (this.tileManager !== null) {
|
||||
if (!(this.tileManager instanceof OpenLayers.TileManager)) {
|
||||
this.tileManager = new OpenLayers.TileManager(this.tileManager);
|
||||
}
|
||||
this.tileManager.addMap(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,18 +65,16 @@ This was necessary for WCS support because there are no properties in common bet
|
||||
|
||||
## Layer.Grid: Tile queue and tileLoadingDelay changes
|
||||
|
||||
With the introduction of OpenLayers.TileManager, tile queueing has become optional. The default behavior is back to how it was in OpenLayers 2.11. To use a tile queue in 2.13, the map needs to be configured with a tileManager, e.g.:
|
||||
With the introduction of OpenLayers.TileManager, tile queueing has become optional but is enabled by default. To not use a tile queue in 2.13, the map needs to be configured with tileManager: null, e.g.:
|
||||
|
||||
var map = new OpenLayers.Map('map', {
|
||||
tileManager: new OpenLayers.TileManager()
|
||||
tileManager: null
|
||||
});
|
||||
|
||||
The tile queue also works differently than before: it no longer loads one tile at a time. Instead, it waits after a zoom or pan, and loads all tiles after a delay. This has the same effect as previously (less burden on the server), but makes use of the browser's request management. The delay can be configured separately for zooming and moving the map, using the `zoomDelay` (default: 200 ms) and `moveDelay` (default: 100 ms) config options of the TileManager.
|
||||
The tile queue works differently than before: it no longer loads one tile at a time. Instead, it waits after a zoom or pan, and loads all tiles after a delay. This has the same effect as previously (less burden on the server), but makes use of the browser's request management. The delay can be configured separately for zooming and moving the map, using the `zoomDelay` (default: 200 ms) and `moveDelay` (default: 100 ms) config options of the TileManager. If you want to have the map be associated with a TileManager with non-default options, supply the options instead or create your own TileManager instance and supply it to the Map constructor.
|
||||
|
||||
The `moveDelay` is the replacement for the `tileLoadingDelay` layer config option, which has been removed. There is no magic any more to only use the delay when requestAnimationFrame is not natively available.
|
||||
|
||||
In general, when targeting mobile devices or when using slow servers or connections for tiled layers, it is recommended to configure the map with a TileManager.
|
||||
|
||||
## Layer.Grid: Resize transitions by default
|
||||
|
||||
The `transitionEffect` property for grid layers has been changed to "resize" by default. This allows smooth transitions with animated zooming (also enabled by default). If resize transitions are not wanted for individual layers, set `transitionEffect` to `null`.
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
});
|
||||
map = new OpenLayers.Map({
|
||||
div: "map",
|
||||
tileManager: null,
|
||||
projection: "EPSG:900913",
|
||||
layers: [layer],
|
||||
center: [0, 0],
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
t.plan( 6 );
|
||||
|
||||
layer = new OpenLayers.Layer.ArcGIS93Rest(name, url, params);
|
||||
var map = new OpenLayers.Map('map');
|
||||
var map = new OpenLayers.Map('map', {tileManager: null});
|
||||
map.addLayer(layer);
|
||||
var pixel = new OpenLayers.Pixel(5,6);
|
||||
var tile = layer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel);
|
||||
@@ -258,7 +258,7 @@
|
||||
t.plan( 9 );
|
||||
|
||||
layer = new OpenLayers.Layer.ArcGIS93Rest(name, url, params);
|
||||
var map = new OpenLayers.Map('map');
|
||||
var map = new OpenLayers.Map('map', {tileManager: null});
|
||||
map.addLayer(layer);
|
||||
var pixel = new OpenLayers.Pixel(5,6);
|
||||
var tile = layer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel);
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
|
||||
function test_setMap(t) {
|
||||
t.plan(1);
|
||||
var map = new OpenLayers.Map('map');
|
||||
var map = new OpenLayers.Map('map', {tileManager: null});
|
||||
layer = new OpenLayers.Layer.Grid(name, url, params, null);
|
||||
map.addLayer(layer);
|
||||
t.ok(OpenLayers.Element.hasClass(layer.div, "olLayerGrid"),
|
||||
@@ -1130,7 +1130,7 @@
|
||||
|
||||
function test_backbuffer_replace(t) {
|
||||
t.plan(6);
|
||||
var map = new OpenLayers.Map('map');
|
||||
var map = new OpenLayers.Map('map', {tileManager: null});
|
||||
var layer = new OpenLayers.Layer.WMS('', '../../img/blank.gif');
|
||||
map.addLayer(layer);
|
||||
map.zoomToMaxExtent();
|
||||
@@ -1220,7 +1220,8 @@
|
||||
|
||||
var map = new OpenLayers.Map('map', {
|
||||
resolutions: [32, 16, 8, 4, 2, 1],
|
||||
zoomMethod: null
|
||||
zoomMethod: null,
|
||||
tileManager: null
|
||||
});
|
||||
var layer = new OpenLayers.Layer.WMS(
|
||||
"WMS",
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
var url = "http://labs.metacarta.com/cgi-bin/mapserv";
|
||||
layer = new OpenLayers.Layer.MapServer(name, url, params);
|
||||
var map = new OpenLayers.Map('map');
|
||||
var map = new OpenLayers.Map('map', {tileManager: null});
|
||||
map.addLayer(layer);
|
||||
var pixel = new OpenLayers.Pixel(5,6);
|
||||
var tile = layer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel);
|
||||
|
||||
@@ -32,7 +32,8 @@
|
||||
projection: "EPSG:900913",
|
||||
layers: [layer],
|
||||
center: [0, 0],
|
||||
zoom: 1
|
||||
zoom: 1,
|
||||
tileManager: null
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
|
||||
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
|
||||
layer = new OpenLayers.Layer.WMS(name, url, params);
|
||||
var map = new OpenLayers.Map('map');
|
||||
var map = new OpenLayers.Map('map', {tileManager: null});
|
||||
map.addLayer(layer);
|
||||
var pixel = new OpenLayers.Pixel(5,6);
|
||||
var tile = layer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel);
|
||||
@@ -104,7 +104,7 @@
|
||||
|
||||
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
|
||||
layer = new OpenLayers.Layer.WMS(name, url, params, {encodeBBOX:true});
|
||||
var map = new OpenLayers.Map('map');
|
||||
var map = new OpenLayers.Map('map', {tileManager: null});
|
||||
map.addLayer(layer);
|
||||
var pixel = new OpenLayers.Pixel(5,6);
|
||||
var tile = layer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel);
|
||||
|
||||
@@ -134,7 +134,7 @@
|
||||
|
||||
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
|
||||
layer = new OpenLayers.Layer.WMS(name, url, params, {'wrapDateLine':true,encodeBBOX:true, buffer: 2});
|
||||
var m = new OpenLayers.Map('map', {adjustZoom: function(z) {return z;}});
|
||||
var m = new OpenLayers.Map('map', {tileManager: null, adjustZoom: function(z) {return z;}});
|
||||
m.addLayer(layer);
|
||||
m.zoomToMaxExtent();
|
||||
t.eq(layer.grid[3][0].url, "http://octo.metacarta.com/cgi-bin/mapserv?MAP=%2Fmapdata%2Fvmap_wms.map&LAYERS=basic&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A4326&BBOX=0%2C-90%2C180%2C90&WIDTH=256&HEIGHT=256", "cell [3][0] is wrapped around the world.");
|
||||
@@ -151,7 +151,7 @@
|
||||
"http://www.openlayers.org/world/index.php",
|
||||
{g: "satellite", map: "world"},
|
||||
{wrapDateLine: true, buffer: 2} );
|
||||
var m = new OpenLayers.Map('map', {adjustZoom: function(z) {return z;}});
|
||||
var m = new OpenLayers.Map('map', {tileManager: null, adjustZoom: function(z) {return z;}});
|
||||
m.addLayer(layer);
|
||||
m.zoomToMaxExtent();
|
||||
t.eq(layer.grid[4][7].url, "http://www.openlayers.org/world/index.php?g=satellite&map=world&i=jpeg&t=0&l=-256&s=221471921.25", "grid[5][7] kamap is okay");
|
||||
@@ -170,7 +170,7 @@
|
||||
"prov_bound,fedlimit,rail,road,popplace",
|
||||
transparent: "true", format: "image/png"},
|
||||
{wrapDateLine: true, encodeBBOX:true, buffer:2});
|
||||
var m = new OpenLayers.Map('map', {adjustZoom: function(z) {return z;}});
|
||||
var m = new OpenLayers.Map('map', {tileManager: null, adjustZoom: function(z) {return z;}});
|
||||
m.addLayers([baselayer,layer]);
|
||||
m.zoomToMaxExtent();
|
||||
t.eq(layer.grid[3][0].url, "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap?LAYERS=bathymetry%2Cland_fn%2Cpark%2Cdrain_fn%2Cdrainage%2Cprov_bound%2Cfedlimit%2Crail%2Croad%2Cpopplace&TRANSPARENT=true&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A4326&BBOX=0%2C-90%2C180%2C90&WIDTH=256&HEIGHT=256", "grid[0][0] wms overlay is okay");
|
||||
|
||||
@@ -193,6 +193,7 @@
|
||||
// test that events.on is called at map construction
|
||||
var options = {
|
||||
eventListeners: {foo: "bar"},
|
||||
tileManager: null,
|
||||
controls: []
|
||||
};
|
||||
OpenLayers.Events.prototype.on = function(obj) {
|
||||
@@ -207,7 +208,7 @@
|
||||
OpenLayers.Events.prototype.on = function(obj) {
|
||||
t.fail("events.on called without eventListeners");
|
||||
}
|
||||
var map2 = new OpenLayers.Map("map", {controls: []});
|
||||
var map2 = new OpenLayers.Map("map", {tileManager: null, controls: []});
|
||||
OpenLayers.Events.prototype.on = method;
|
||||
map2.destroy();
|
||||
}
|
||||
@@ -2249,6 +2250,20 @@
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_tileManager(t) {
|
||||
t.plan(3);
|
||||
var map = new OpenLayers.Map('map');
|
||||
t.ok(map.tileManager instanceof OpenLayers.TileManager, "Default tileManager created");
|
||||
map.destroy();
|
||||
map = new OpenLayers.Map('map', {tileManager: null});
|
||||
t.ok(map.tileManager === null, "No tileManager created");
|
||||
map.destroy();
|
||||
var options = {cacheSize: 512};
|
||||
map = new OpenLayers.Map('map', {tileManager: options});
|
||||
t.eq(map.tileManager.cacheSize, 512, "cacheSize taken from options");
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
function test_Tile_Image_IFrame_create (t) {
|
||||
t.plan( 3 );
|
||||
map = new OpenLayers.Map('map');
|
||||
map = new OpenLayers.Map('map', {tileManager: null});
|
||||
var bar = new Array(205).join("1234567890");
|
||||
layer = new OpenLayers.Layer.WMS(name, wmsUrl,
|
||||
{layers: 'basic', foo: bar},
|
||||
@@ -87,7 +87,7 @@
|
||||
function test_Tile_Image_IFrame_createImage (t) {
|
||||
t.plan( 9 );
|
||||
|
||||
map = new OpenLayers.Map('map');
|
||||
map = new OpenLayers.Map('map', {tileManager: null});
|
||||
layer = new OpenLayers.Layer.WMS(name, wmsUrl, {layers: 'basic'}, {tileOptions: {maxGetUrlLength: 0}});
|
||||
map.addLayer(layer);
|
||||
var tile = layer.addTile(bounds, position);
|
||||
|
||||
@@ -32,7 +32,8 @@
|
||||
projection: "EPSG:900913",
|
||||
layers: [layer],
|
||||
center: [0, 0],
|
||||
zoom: 1
|
||||
zoom: 1,
|
||||
tileManager: null
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -134,4 +134,4 @@
|
||||
<body>
|
||||
<div id="map" style="width:499px;height:549px;display:none"></div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
function test_Layer_MapServer_Untiled_mergeNewParams (t) {
|
||||
t.plan( 5 );
|
||||
|
||||
var map = new OpenLayers.Map("map");
|
||||
var map = new OpenLayers.Map("map", {tileManager: null});
|
||||
var url = "http://labs.metacarta.com/cgi-bin/mapserv";
|
||||
layer = new OpenLayers.Layer.MapServer.Untiled(name, url, params);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user