Compare commits

..

4 Commits

Author SHA1 Message Date
Bart van den Eijnden
1c21d9cc15 Merge pull request #998 from bartvde/tilemgrdefault
enable TileManager by default as suggested by @marcjansen and @bartvde ... (r=@ahocevar)
2013-06-06 14:18:18 +02:00
ahocevar
4d52d4aeb5 Drag interval of 0 (i.e. no separate cycle) seems appropriate now
The reason for setting this to 1 was ancient IPhones with ancient iOS
versions. On all other devices, 0 seems to work better, and it removes the
overhead of spawning a separate cycle for each drag.
2013-06-06 13:38:13 +02:00
Bart van den Eijnden
1e94821042 set VERSION_NUMBER to 2.13-rc6 2013-06-06 09:19:42 +02:00
ahocevar
8cccbfb189 Protect ZoomBox from division by zero
When the map is at the highest zoom level, the old and the current
resolution will be the same. This would cause a division by zero, which
the JavaScript engine does not recognize as such. So we have to protect
zoomOriginPx from becoming {x: Infinity, y: Infinity}.
2013-06-06 09:18:35 +02:00
22 changed files with 65 additions and 43 deletions

View File

@@ -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]

View File

@@ -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})

View File

@@ -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({

View File

@@ -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(),

View File

@@ -426,4 +426,4 @@
* When asking questions or reporting issues, make sure to include the output of
* OpenLayers.VERSION_NUMBER in the question or issue-description.
*/
OpenLayers.VERSION_NUMBER="Release 2.13-rc5";
OpenLayers.VERSION_NUMBER="Release 2.13-rc6";

View File

@@ -32,11 +32,12 @@ OpenLayers.Control.DragPan = OpenLayers.Class(OpenLayers.Control, {
/**
* Property: interval
* {Integer} The number of milliseconds that should ellapse before
* panning the map again. Defaults to 1 millisecond. In most cases
* you won't want to change this value. For slow machines/devices
* larger values can be tried out.
* panning the map again. Defaults to 0 milliseconds, which means that
* no separate cycle is used for panning. In most cases you won't want
* to change this value. For slow machines/devices larger values can be
* tried out.
*/
interval: 1,
interval: 0,
/**
* APIProperty: documentDrag

View File

@@ -101,14 +101,18 @@ OpenLayers.Control.ZoomBox = OpenLayers.Class(OpenLayers.Control, {
centerPx = {x: size.w / 2, y: size.h / 2},
zoom = this.map.getZoomForExtent(bounds),
oldRes = this.map.getResolution(),
newRes = this.map.getResolutionForZoom(zoom),
zoomOriginPx = {
newRes = this.map.getResolutionForZoom(zoom);
if (oldRes == newRes) {
this.map.setCenter(this.map.getLonLatFromPixel(targetCenterPx));
} else {
var zoomOriginPx = {
x: (oldRes * targetCenterPx.x - newRes * centerPx.x) /
(oldRes - newRes),
y: (oldRes * targetCenterPx.y - newRes * centerPx.y) /
(oldRes - newRes)
};
this.map.zoomTo(zoom, zoomOriginPx);
this.map.zoomTo(zoom, zoomOriginPx);
}
if (lastZoom == this.map.getZoom() && this.alwaysZoom == true){
this.map.zoomTo(lastZoom + (this.out ? -1 : 1));
}

View File

@@ -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);
}

View File

@@ -7,7 +7,7 @@ var OpenLayers = {
/**
* Constant: VERSION_NUMBER
*/
VERSION_NUMBER: "Release 2.13-rc5",
VERSION_NUMBER: "Release 2.13-rc6",
/**
* Constant: singleFile

View File

@@ -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`.

View File

@@ -30,6 +30,7 @@
});
map = new OpenLayers.Map({
div: "map",
tileManager: null,
projection: "EPSG:900913",
layers: [layer],
center: [0, 0],

View File

@@ -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);

View File

@@ -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",

View File

@@ -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);

View File

@@ -32,7 +32,8 @@
projection: "EPSG:900913",
layers: [layer],
center: [0, 0],
zoom: 1
zoom: 1,
tileManager: null
});
}

View File

@@ -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);

View File

@@ -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");

View File

@@ -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>

View File

@@ -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);

View File

@@ -32,7 +32,8 @@
projection: "EPSG:900913",
layers: [layer],
center: [0, 0],
zoom: 1
zoom: 1,
tileManager: null
});
}

View File

@@ -134,4 +134,4 @@
<body>
<div id="map" style="width:499px;height:549px;display:none"></div>
</body>
</html>
</html>

View File

@@ -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);