diff --git a/examples/all-overlays-google.html b/examples/all-overlays-google.html index 9df8cff1d3..3b7790eea9 100644 --- a/examples/all-overlays-google.html +++ b/examples/all-overlays-google.html @@ -8,7 +8,7 @@ - + diff --git a/examples/editing-methods.js b/examples/editing-methods.js index 6c139a276d..03d5e82311 100644 --- a/examples/editing-methods.js +++ b/examples/editing-methods.js @@ -20,7 +20,7 @@ map.addControl(draw); draw.activate(); // handle clicks on method links -$("insertXY").onclick = function() { +document.getElementById("insertXY").onclick = function() { var values = parseInput( window.prompt( "Enter map coordinates for new point (e.g. '-111, 46')", "x, y" @@ -30,7 +30,7 @@ $("insertXY").onclick = function() { draw.insertXY(values[0], values[1]); } }; -$("insertDeltaXY").onclick = function() { +document.getElementById("insertDeltaXY").onclick = function() { var values = parseInput( window.prompt( "Enter offset values for new point (e.g. '15, -10')", "dx, dy" @@ -40,7 +40,7 @@ $("insertDeltaXY").onclick = function() { draw.insertDeltaXY(values[0], values[1]); } }; -$("insertDirectionLength").onclick = function() { +document.getElementById("insertDirectionLength").onclick = function() { var values = parseInput( window.prompt( "Enter direction and length offset values for new point (e.g. '-45, 10')", "direction, length" @@ -50,7 +50,7 @@ $("insertDirectionLength").onclick = function() { draw.insertDirectionLength(values[0], values[1]); } }; -$("insertDeflectionLength").onclick = function() { +document.getElementById("insertDeflectionLength").onclick = function() { var values = parseInput( window.prompt( "Enter deflection and length offset values for new point (e.g. '15, 20')", "deflection, length" @@ -60,10 +60,10 @@ $("insertDeflectionLength").onclick = function() { draw.insertDeflectionLength(values[0], values[1]); } }; -$("cancel").onclick = function() { +document.getElementById("cancel").onclick = function() { draw.cancel(); }; -$("finishSketch").onclick = function() { +document.getElementById("finishSketch").onclick = function() { draw.finishSketch(); }; diff --git a/examples/game-accel-ball.html b/examples/game-accel-ball.html index 40bb02d791..c832e86721 100644 --- a/examples/game-accel-ball.html +++ b/examples/game-accel-ball.html @@ -35,7 +35,7 @@ function init() { map = new OpenLayers.Map( 'map', { - 'maxExtent': new OpenLayers.Bounds(0, 0, $("map").clientWidth, $("map").clientHeight), + 'maxExtent': new OpenLayers.Bounds(0, 0, document.getElementById("map").clientWidth, document.getElementById("map").clientHeight), controls: [], maxResolution: 'auto'} ); diff --git a/examples/geolocation.js b/examples/geolocation.js index 1afc12d997..3d8d6f4b55 100644 --- a/examples/geolocation.js +++ b/examples/geolocation.js @@ -92,16 +92,15 @@ geolocate.events.register("locationupdated",geolocate,function(e) { geolocate.events.register("locationfailed",this,function() { OpenLayers.Console.log('Location detection failed'); }); - -$('locate').onclick = function() { +document.getElementById('locate').onclick = function() { vector.removeAllFeatures(); geolocate.deactivate(); - $('track').checked = false; + document.getElementById('track').checked = false; geolocate.watch = false; firstGeolocation = true; geolocate.activate(); }; -$('track').onclick = function() { +document.getElementById('track').onclick = function() { vector.removeAllFeatures(); geolocate.deactivate(); if (this.checked) { @@ -110,4 +109,4 @@ $('track').onclick = function() { geolocate.activate(); } }; -$('track').checked = false; +document.getElementById('track').checked = false; diff --git a/examples/getfeatureinfo-control.html b/examples/getfeatureinfo-control.html index cb0bec10e4..baecd420fb 100644 --- a/examples/getfeatureinfo-control.html +++ b/examples/getfeatureinfo-control.html @@ -48,7 +48,6 @@ + diff --git a/examples/google-v3.html b/examples/google-v3.html index 8b4a348b9b..4365dafbf8 100644 --- a/examples/google-v3.html +++ b/examples/google-v3.html @@ -8,7 +8,7 @@ - + @@ -35,6 +35,17 @@ location, you must include the extra theme/default/google.css stylesheet.

+

+ Note on Google Maps API versioning: + This example uses the "nightly" version of Google Maps + API. This is specified by using v=3 in the + the Google Maps API URL. Production applications should use the + "release" or "frozen" versions of Google Maps + API. See the OpenLayers.Layer.Google.v3 API + docs, and the + Versioning Section + of the Google Maps API docs, for more details. +

diff --git a/examples/mobile-wmts-vienna.js b/examples/mobile-wmts-vienna.js index 8c118d6f6e..91d3a7105d 100644 --- a/examples/mobile-wmts-vienna.js +++ b/examples/mobile-wmts-vienna.js @@ -163,8 +163,8 @@ var map; {layer:"lb", requestEncoding:"REST", transitionEffect:"resize"}, defaults )); labels = format.createLayer(caps, OpenLayers.Util.applyDefaults( - {layer:"beschriftung", requestEncoding:"REST", isBaseLayer: false}, - OpenLayers.Util.extend({className: "nofade"}, defaults) + {layer:"beschriftung", requestEncoding:"REST", className:"nofade", isBaseLayer: false}, + defaults )); map.addLayers([fmzk, aerial, labels]); zoomToInitialExtent(); @@ -184,21 +184,21 @@ var map; attribution: 'Datenquelle: Stadt Wien - data.wien.gv.at' }; fmzk = new OpenLayers.Layer.WMTS(OpenLayers.Util.applyDefaults({ - url: "http://www.wien.gv.at/wmts/fmzk/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.jpeg", + url: "http://maps.wien.gv.at/wmts/fmzk/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.jpeg", layer: "fmzk", style: "pastell", transitionEffect: "resize" }, defaults)); aerial = new OpenLayers.Layer.WMTS(OpenLayers.Util.applyDefaults({ - url: "http://www.wien.gv.at/wmts/lb/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.jpeg", + url: "http://maps.wien.gv.at/wmts/lb/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.jpeg", layer: "lb", style: "farbe", transitionEffect: "resize" }, defaults)); labels = new OpenLayers.Layer.WMTS(OpenLayers.Util.applyDefaults({ - url: "http://www.wien.gv.at/wmts/beschriftung/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png", + url: "http://maps.wien.gv.at/wmts/beschriftung/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png", layer: "beschriftung", style: "normal", transitionEffect: null, diff --git a/examples/osm-google.html b/examples/osm-google.html index a09cba59dd..066dadc61e 100644 --- a/examples/osm-google.html +++ b/examples/osm-google.html @@ -8,7 +8,7 @@ - + diff --git a/examples/overviewmap.html b/examples/overviewmap.html index 165c987e8b..5a8cc3fbc9 100644 --- a/examples/overviewmap.html +++ b/examples/overviewmap.html @@ -80,7 +80,9 @@ // create an overview map control with the default options var overview1 = new OpenLayers.Control.OverviewMap({ - maximized: true + maximized: true, + maximizeTitle: 'Show the overview map', + minimizeTitle: 'Hide the overview map' }); map1.addControl(overview1); diff --git a/examples/select-feature.html b/examples/select-feature.html index 00325a4d7c..fe5243e711 100644 --- a/examples/select-feature.html +++ b/examples/select-feature.html @@ -15,6 +15,7 @@ + diff --git a/examples/strategy-cluster-extended.js b/examples/strategy-cluster-extended.js index 70928c4492..163cbf47d5 100644 --- a/examples/strategy-cluster-extended.js +++ b/examples/strategy-cluster-extended.js @@ -73,67 +73,67 @@ var map, vectorlayer, features, stylemap, select; // The function that gets called on feature selection: shows information // about the feature/cluser in a div on the page - var showInformation = function(evt){ + var showInformation = function(evt){ var feature = evt.feature; - var info = 'Last hovered feature:
'; - if (feature.cluster) { - info += '  Cluster of ' + feature.attributes.count + ' features:'; - var clazzes = { - '1': 0, - '2': 0, - '3': 0, - '4': 0 - }; - for (var i = 0; i < feature.attributes.count; i++) { - var feat = feature.cluster[i]; - clazzes[feat.attributes.clazz]++; - } - for (var j=1; j<=4; j++) { - var plural_s = (clazzes[j] !== 1) ? 's' : ''; - info += '
    • clazz ' + j + ': ' + clazzes[j] + ' feature' + plural_s; - } - } else { - info += '  Single feature of clazz = ' + feature.attributes.clazz; - } - $('info').innerHTML = info; + var info = 'Last hovered feature:
'; + if (feature.cluster) { + info += '  Cluster of ' + feature.attributes.count + ' features:'; + var clazzes = { + '1': 0, + '2': 0, + '3': 0, + '4': 0 + }; + for (var i = 0; i < feature.attributes.count; i++) { + var feat = feature.cluster[i]; + clazzes[feat.attributes.clazz]++; + } + for (var j=1; j<=4; j++) { + var plural_s = (clazzes[j] !== 1) ? 's' : ''; + info += '
    • clazz ' + j + ': ' + clazzes[j] + ' feature' + plural_s; + } + } else { + info += '  Single feature of clazz = ' + feature.attributes.clazz; + } + document.getElementById('info').innerHTML = info; }; - // The function that gets called on feature selection. Shows information + // The function that gets called on feature selection. Shows information // about the number of "points" on the map. - var updateGeneralInformation = function() { - var info = 'Currently ' + vectorlayer.features.length + ' points are shown on the map.'; - $('generalinfo').innerHTML = info; - }; - - // instanciate the map - map = new OpenLayers.Map("map"); + var updateGeneralInformation = function() { + var info = 'Currently ' + vectorlayer.features.length + ' points are shown on the map.'; + document.getElementById('generalinfo').innerHTML = info; + }; - // background WMS + // instanciate the map + map = new OpenLayers.Map("map"); + + // background WMS var ol_wms = new OpenLayers.Layer.WMS("OpenLayers WMS", "http://vmap0.tiles.osgeo.org/wms/vmap0", { layers: "basic" }); - // context to style the vectorlayer + // context to style the vectorlayer var context = { getColor: function(feature){ var color = '#aaaaaa'; - if (feature.attributes.clazz && feature.attributes.clazz === 4) { - color = '#ee0000'; - } else if(feature.cluster) { - var onlyFour = true; - for (var i = 0; i < feature.cluster.length; i++) { - if (onlyFour && feature.cluster[i].attributes.clazz !== 4) { - onlyFour = false; - } - } - if (onlyFour === true) { - color = '#ee0000'; - } - } - return color; + if (feature.attributes.clazz && feature.attributes.clazz === 4) { + color = '#ee0000'; + } else if(feature.cluster) { + var onlyFour = true; + for (var i = 0; i < feature.cluster.length; i++) { + if (onlyFour && feature.cluster[i].attributes.clazz !== 4) { + onlyFour = false; + } + } + if (onlyFour === true) { + color = '#ee0000'; + } + } + return color; } }; - + // style the vectorlayer stylemap = new OpenLayers.StyleMap({ 'default': new OpenLayers.Style({ @@ -143,32 +143,32 @@ var map, vectorlayer, features, stylemap, select; strokeColor: "#666666", strokeWidth: 1, strokeOpacity: 1, - graphicZIndex: 1 + graphicZIndex: 1 }, { context: context }), - 'select' : new OpenLayers.Style({ + 'select' : new OpenLayers.Style({ pointRadius: 5, fillColor: "#ffff00", fillOpacity: 1, strokeColor: "#666666", strokeWidth: 1, strokeOpacity: 1, - graphicZIndex: 2 + graphicZIndex: 2 }) }); // the vectorlayer vectorlayer = new OpenLayers.Layer.Vector('Vectorlayer', {styleMap: stylemap, strategies: []}); - // the select control - select = new OpenLayers.Control.SelectFeature( + // the select control + select = new OpenLayers.Control.SelectFeature( vectorlayer, {hover: true} ); map.addControl(select); select.activate(); vectorlayer.events.on({"featureselected": showInformation}); - + map.addLayers([ol_wms, vectorlayer]); map.addControl(new OpenLayers.Control.LayerSwitcher()); map.zoomToMaxExtent(); @@ -197,18 +197,18 @@ var map, vectorlayer, features, stylemap, select; switch(this.value) { case 'cluster': // standard clustering - strategies.push(new OpenLayers.Strategy.Cluster()); + strategies.push(new OpenLayers.Strategy.Cluster()); break; case 'attribute-cluster': // use the custom class: only cluster features of the same clazz - strategies.push(new OpenLayers.Strategy.AttributeCluster({ + strategies.push(new OpenLayers.Strategy.AttributeCluster({ attribute:'clazz' })); break; case 'rule-cluster': // use the custom class: only cluster features that have a - // clazz smaller than 4 - strategies.push(new OpenLayers.Strategy.RuleCluster({ + // clazz smaller than 4 + strategies.push(new OpenLayers.Strategy.RuleCluster({ rule: new OpenLayers.Rule({ filter: new OpenLayers.Filter.Comparison({ type: OpenLayers.Filter.Comparison.LESS_THAN, @@ -219,24 +219,24 @@ var map, vectorlayer, features, stylemap, select; })); break; } - // remove layer and control + // remove layer and control map.removeLayer(vectorlayer); - map.removeControl(select); - // rebuild layer + map.removeControl(select); + // rebuild layer vectorlayer = new OpenLayers.Layer.Vector('Vectorlayer', {styleMap: stylemap, strategies: strategies}); map.addLayer( vectorlayer ); vectorlayer.addFeatures(features); // rebuild select control - select = new OpenLayers.Control.SelectFeature( - vectorlayer, {hover: true} - ); - map.addControl(select); - select.activate(); - vectorlayer.events.on({"featureselected": showInformation}); - // update meta information - updateGeneralInformation(); + select = new OpenLayers.Control.SelectFeature( + vectorlayer, {hover: true} + ); + map.addControl(select); + select.activate(); + vectorlayer.events.on({"featureselected": showInformation}); + // update meta information + updateGeneralInformation(); }; - // bind the behviour to the radios + // bind the behviour to the radios var inputs = document.getElementsByTagName('input'); for( var cnt = 0; cnt < inputs.length; cnt++) { var input = inputs[cnt]; diff --git a/examples/strategy-cluster-threshold.html b/examples/strategy-cluster-threshold.html index 31c79ce776..13abd2c1ea 100644 --- a/examples/strategy-cluster-threshold.html +++ b/examples/strategy-cluster-threshold.html @@ -18,7 +18,6 @@ + * * (end) + * + * but that development code should use the latest 'nightly' version, so that any + * problems can be dealt with as soon as they arise, and before they affect the production, 'frozen', code. + * + * Note, however, that frozen versions are retired as part of Google's release + * cycle, and once this happens, you will get the next version, in the example above, 3.8 once 3.7 is retired. + * + * This version supports 3.7. + * + * + * Note that this layer configures the google.maps.map object with the + * "disableDefaultUI" option set to true. Using UI controls that the Google + * Maps API provides is not supported by the OpenLayers API. */ OpenLayers.Layer.Google.v3 = { diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index ab83779334..b1d45eebd8 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -1302,19 +1302,20 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { * columns - {Integer} Maximum number of columns we want our grid to have. */ removeExcessTiles: function(rows, columns) { + var i, l; // remove extra rows while (this.grid.length > rows) { var row = this.grid.pop(); - for (var i=0, l=row.length; i columns) { - for (var i=0, l=this.grid.length; i columns) { var row = this.grid[i]; var tile = row.pop(); this.destroyTile(tile); diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index f344a0b7f1..a91f8703ef 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -662,6 +662,7 @@ OpenLayers.Map = OpenLayers.Class({ * be properly set below. */ delete this.center; + delete this.zoom; this.addLayers(options.layers); // set center (and optionally zoom) if (options.center && !this.getCenter()) { diff --git a/lib/OpenLayers/Popup/Anchored.js b/lib/OpenLayers/Popup/Anchored.js index 0795d9fdef..6909908ca8 100644 --- a/lib/OpenLayers/Popup/Anchored.js +++ b/lib/OpenLayers/Popup/Anchored.js @@ -107,11 +107,8 @@ OpenLayers.Popup.Anchored = moveTo: function(px) { var oldRelativePosition = this.relativePosition; this.relativePosition = this.calculateRelativePosition(px); - - var newPx = this.calculateNewPx(px); - - var newArguments = new Array(newPx); - OpenLayers.Popup.prototype.moveTo.apply(this, newArguments); + + OpenLayers.Popup.prototype.moveTo.call(this, this.calculateNewPx(px)); //if this move has caused the popup to change its relative position, // we need to make the appropriate cosmetic changes. diff --git a/lib/OpenLayers/SingleFile.js b/lib/OpenLayers/SingleFile.js index d3f7179301..53fa0ceb8d 100644 --- a/lib/OpenLayers/SingleFile.js +++ b/lib/OpenLayers/SingleFile.js @@ -7,7 +7,7 @@ var OpenLayers = { /** * Constant: VERSION_NUMBER */ - VERSION_NUMBER: "Release 2.12-rc4", + VERSION_NUMBER: "Release 2.12-rc5", /** * Constant: singleFile diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index ac598f2604..0405bad73e 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -74,13 +74,6 @@ OpenLayers.Util.isArray = function(a) { return (Object.prototype.toString.call(a) === '[object Array]'); }; -/** - * Maintain existing definition of $. - */ -if(typeof window.$ === "undefined") { - window.$ = OpenLayers.Util.getElement; -} - /** * Function: removeItem * Remove an object from an array. Iterates through the array diff --git a/lib/deprecated.js b/lib/deprecated.js index 0cc3c1b6aa..a389dc7b62 100644 --- a/lib/deprecated.js +++ b/lib/deprecated.js @@ -164,6 +164,17 @@ OpenLayers.Util.getArgs = function(url) { return OpenLayers.Util.getParameters(url); }; +/** + * Maintain existing definition of $. + * + * The use of our $-method is deprecated and the mapping of + * OpenLayers.Util.getElement will eventually be removed. Do not depend on + * window.$ being defined by OpenLayers. + */ +if(typeof window.$ === "undefined") { + window.$ = OpenLayers.Util.getElement; +} + /** * Namespace: OpenLayers.Ajax */ diff --git a/notes/2.12.md b/notes/2.12.md index 6a6bdb8fee..61c8b71060 100644 --- a/notes/2.12.md +++ b/notes/2.12.md @@ -219,6 +219,20 @@ Corresponding issues/pull requests: * https://github.com/openlayers/openlayers/pull/101 +## Google v3 Layer + +This release fixes a problem with the clickable elements supplied by Google. `OpenLayers.Layer.Google.v3` is now compatible with the current frozen version of Google's API (3.7) and also with the current release and nightly versions (3.8 and 3.9), but be aware that Google may change these elements in their release and nightly versions at any time, and an interim fix OpenLayers release may be needed. + +It's recommended that production servers always load the frozen version of Google's API, but it would help find potential problems if development pages used the latest nightly version. + +See the class description in the API docs for `OpenLayers.Layer.Google.v3` for more details. + +Good ideas on how to improve this unsatisfactory situation welcome! + +Corresponding issues/pull requests: + + * https://github.com/openlayers/openlayers/pull/472 + ## OSM and Bing Layers `Layer.OSM` is now defined in its own script file, namely `OpenLayers/Layer/OSM.js`. So people using `Layer.OSM` should now include `OpenLayers/Layer/OSM.js`, as opposed to `OpenLayers/Layer/XYZ.js`, in their OpenLayers builds. diff --git a/notes/2.13.md b/notes/2.13.md index c8d0938d6c..f827ac77d3 100644 --- a/notes/2.13.md +++ b/notes/2.13.md @@ -7,3 +7,31 @@ Previously, objects generated by the library were given id properties with value Corresponding issues/pull requests: * https://github.com/openlayers/openlayers/pull/416 + +## Better support for analog scroll wheel + +Removed rounding of zoom level for maps with fractionalZoom == true. So users with an OS and interface device with analog scroll support will now get smooth zooming. + +Corresponding issues/pull requests: + + * https://github.com/openlayers/openlayers/pull/483 + +# Behavior Changes from Past Releases + +## window.$ is no longer an alias for OpenLayers.Util.getElement + +We do no longer create a global variable '$' when such a symbol isn't already +defined. Previous versions of OpenLayers would define '$' to be an alias for +OpenLayers.Util.getElement. If your application requires window.$ to be defined +in such a way you can either + +* include deprecated.js in your custom build or as additional ressource in your + HTML-file +* or you do the aliasing in your application code yourself: + + window.$ = OpenLayers.Util.getElement; + +Corresponding issue/pull requests: + +* https://github.com/openlayers/openlayers/pull/423 + diff --git a/tests/Control/OverviewMap.html b/tests/Control/OverviewMap.html index 6548e21e59..a5a598d0d5 100644 --- a/tests/Control/OverviewMap.html +++ b/tests/Control/OverviewMap.html @@ -14,6 +14,23 @@ "olControlOverviewMap", "displayClass is correct" ); } + function test_divs_title(t) { + t.plan(2); + + control = new OpenLayers.Control.OverviewMap({ + maximizeTitle: "maximize title", + minimizeTitle: "minimize title" + }); + map = new OpenLayers.Map('map', { + layers: [new OpenLayers.Layer("layer", {isBaseLayer: true})], + controls: [control] + }); + map.zoomToMaxExtent(); + t.eq(control.maximizeDiv.title, "maximize title", "maximizeDiv.title is correct"); + t.eq(control.minimizeDiv.title, "minimize title", "minimizeDiv.title is correct"); + map.destroy(); + } + function test_setMap(t) { t.plan(4); diff --git a/tests/Format/KML.html b/tests/Format/KML.html index a7dfd976c2..556e70993c 100644 --- a/tests/Format/KML.html +++ b/tests/Format/KML.html @@ -236,13 +236,13 @@ var f = new OpenLayers.Format.KML(); t.eq(f.read(f.write(feature))[0].attributes.name, feature.id, "placemark name from feature.id"); - - feature.attributes.name = "placemark name from attributes.name"; - t.eq(f.read(f.write(feature))[0].attributes.name, feature.attributes.name, "placemark name from attributes.name"); feature.style = { label: "placemark name from style.label" }; t.eq(f.read(f.write(feature))[0].attributes.name, feature.style.label, "placemark name from style.label"); + + feature.attributes.name = "placemark name from attributes.name"; + t.eq(f.read(f.write(feature))[0].attributes.name, feature.attributes.name, "placemark name from attributes.name"); } function test_Format_KML_linestring_projected(t) { t.plan(1); diff --git a/tests/Handler/MouseWheel.html b/tests/Handler/MouseWheel.html index d41c2cd18c..0ec9505fb7 100644 --- a/tests/Handler/MouseWheel.html +++ b/tests/Handler/MouseWheel.html @@ -108,7 +108,7 @@ var activated = handler.activate(); var delta = 120; - if (window.opera && window.opera.version() < 9.2) delta = -delta; + if (window.opera && window.opera.version() < 9.2) { delta = -delta; } handler.onWheelEvent({'target':map.layers[0].div, wheelDelta: delta}); handler.onWheelEvent({'target':map.layers[0].div, wheelDelta: delta}); t.delay_call(1, function() { diff --git a/tests/Layer/Grid.html b/tests/Layer/Grid.html index bb632d1ea5..981ccb4e83 100644 --- a/tests/Layer/Grid.html +++ b/tests/Layer/Grid.html @@ -1523,6 +1523,70 @@ map.destroy(); } + + function test_removeExcessTiles(t) { + t.plan(15); + + /* + * Set up + */ + + var map = new OpenLayers.Map('map'); + var layer = new OpenLayers.Layer.Grid('name', '/url', + {}, {isBaseLayer: true}); + map.addLayer(layer); + + function newTile(id) { + var t = new OpenLayers.Tile(layer, + new OpenLayers.Pixel(1, 1), + new OpenLayers.Bounds(1, 1, 1, 1)); + t._id = id; + return t; + } + + layer.grid = [ + [newTile(1), newTile(2), newTile(3)], + [newTile(4), newTile(5)], + [newTile(6), newTile(7), newTile(8)] + ]; + + // create a clone to be able to test whether + // tiles have been destroyed or not + var grid = [ + layer.grid[0].slice(), + layer.grid[1].slice(), + layer.grid[2].slice() + ]; + + /* + * Test + */ + + layer.removeExcessTiles(2, 2); + + t.eq(layer.grid.length, 2, 'grid has two rows'); + t.eq(layer.grid[0].length, 2, 'row #1 has two columns'); + t.eq(layer.grid[0][0]._id, 1, 'row #1 col #1 includes expected tile'); + t.eq(layer.grid[0][1]._id, 2, 'row #1 col #2 includes expected tile'); + t.eq(layer.grid[1].length, 2, 'row #2 has two columns'); + t.eq(layer.grid[1][0]._id, 4, 'row #2 col #1 includes expected tile'); + t.eq(layer.grid[1][1]._id, 5, 'row #2 col #2 includes expected tile'); + + t.ok(grid[0][0].events != null, 'tile 0,0 not destroyed'); + t.ok(grid[0][1].events != null, 'tile 0,1 not destroyed'); + t.ok(grid[0][2].events == null, 'tile 0,2 destroyed'); + t.ok(grid[1][0].events != null, 'tile 1,0 not destroyed'); + t.ok(grid[1][1].events != null, 'tile 1,1 not destroyed'); + t.ok(grid[2][0].events == null, 'tile 2,0 destroyed'); + t.ok(grid[2][1].events == null, 'tile 2,1 destroyed'); + t.ok(grid[2][2].events == null, 'tile 2,2 destroyed'); + + /* + * Tear down + */ + + map.destroy(); + } diff --git a/tests/Map.html b/tests/Map.html index 860ba3360a..e09f132442 100644 --- a/tests/Map.html +++ b/tests/Map.html @@ -748,7 +748,7 @@ function test_Map_double_addLayer(t) { t.plan(2); - map = new OpenLayers.Map($('map')); + map = new OpenLayers.Map('map'); layer = new OpenLayers.Layer.WMS('Test Layer', "http://octo.metacarta.com/cgi-bin/mapserv", {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'} diff --git a/tests/Util.html b/tests/Util.html index ecb583beb0..54393406f2 100644 --- a/tests/Util.html +++ b/tests/Util.html @@ -1,10 +1,6 @@ - + + + + + + + \ No newline at end of file diff --git a/tests/list-tests.html b/tests/list-tests.html index 283bc69eb8..14ccf78ed0 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -231,6 +231,7 @@
  • Kinetic.html
  • Util.html
  • deprecated/Ajax.html
  • +
  • deprecated/Util.html
  • deprecated/BaseTypes/Class.html
  • deprecated/BaseTypes/Element.html
  • deprecated/Control/MouseToolbar.html