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/click.html b/examples/click.html index 094ff2922f..5b6a0253fa 100644 --- a/examples/click.html +++ b/examples/click.html @@ -34,7 +34,7 @@ }, trigger: function(e) { - var lonlat = map.getLonLatFromViewPortPx(e.xy); + var lonlat = map.getLonLatFromPixel(e.xy); alert("You clicked near " + lonlat.lat + " N, " + + lonlat.lon + " E"); } @@ -75,7 +75,7 @@

This example shows the use of the click handler and - getLonLatFromViewPortPx functions to trigger events on mouse click. + getLonLatFromPixel functions to trigger events on mouse click.

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/kml-pointtrack.js b/examples/kml-pointtrack.js index 47836f25fd..7d48ce360f 100644 --- a/examples/kml-pointtrack.js +++ b/examples/kml-pointtrack.js @@ -29,12 +29,13 @@ function init() { var fid, points = [], feature; for (var i=0, len=e.features.length; i + + + + + + OpenLayers MapQuest Demo + + + + +

OpenLayers with MapQuest Tiles

+
+ This example demonstrates the use of MapQuest tiles with OpenLayers. +
+
+ MapQuest, OSM, XYZ +
+
+
+

+ See the mapquest.js source for + detail on using MapQuest tiles in OpenLayers. +

+
+ + + \ No newline at end of file diff --git a/examples/mapquest.js b/examples/mapquest.js new file mode 100644 index 0000000000..9761e897b3 --- /dev/null +++ b/examples/mapquest.js @@ -0,0 +1,36 @@ +var map = new OpenLayers.Map({ + div: "map", + projection: "EPSG:900913", + layers: [ + new OpenLayers.Layer.XYZ( + "OpenStreetMap", + [ + "http://otile1.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png", + "http://otile2.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png", + "http://otile3.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png", + "http://otile4.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png" + ], + { + attribution: "Data, imagery and map information provided by MapQuest, Open Street Map and contributors, CC-BY-SA ", + transitionEffect: "resize" + } + ), + new OpenLayers.Layer.XYZ( + "Imagery", + [ + "http://oatile1.mqcdn.com/naip/${z}/${x}/${y}.png", + "http://oatile2.mqcdn.com/naip/${z}/${x}/${y}.png", + "http://oatile3.mqcdn.com/naip/${z}/${x}/${y}.png", + "http://oatile4.mqcdn.com/naip/${z}/${x}/${y}.png" + ], + { + attribution: "Tiles Courtesy of MapQuest. Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency. ", + transitionEffect: "resize" + } + ) + ], + center: [0, 0], + zoom: 1 +}); + +map.addControl(new OpenLayers.Control.LayerSwitcher()); diff --git a/examples/marker-shadow.html b/examples/marker-shadow.html index 70482555de..a244653a12 100644 --- a/examples/marker-shadow.html +++ b/examples/marker-shadow.html @@ -99,7 +99,7 @@ var pixel = new OpenLayers.Pixel(center.x + x, center.y + y); - var lonLat = map.getLonLatFromViewPortPx(pixel); + var lonLat = map.getLonLatFromPixel(pixel); features.push( new OpenLayers.Feature.Vector( new OpenLayers.Geometry.Point(lonLat.lon, lonLat.lat) diff --git a/examples/mobile-drawing.html b/examples/mobile-drawing.html index 6a91152b89..0cb9c529f1 100644 --- a/examples/mobile-drawing.html +++ b/examples/mobile-drawing.html @@ -5,7 +5,7 @@ - + diff --git a/examples/mobile-jq.html b/examples/mobile-jq.html index 470fd39d5d..5e16caaa68 100644 --- a/examples/mobile-jq.html +++ b/examples/mobile-jq.html @@ -8,7 +8,7 @@ - + diff --git a/examples/mobile-layers.html b/examples/mobile-layers.html index dcb27645f9..d25867477a 100644 --- a/examples/mobile-layers.html +++ b/examples/mobile-layers.html @@ -5,7 +5,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 = { @@ -137,27 +164,31 @@ OpenLayers.Layer.Google.v3 = { var cache = OpenLayers.Layer.Google.cache[this.map.id]; var container = this.map.viewPortDiv; - // move the Map Data popup to the container, if any - while (div.lastChild.style.display == "none") { - container.appendChild(div.lastChild); - } - // move the ToS and branding stuff up to the container div - var termsOfUse = div.lastChild; - container.appendChild(termsOfUse); - termsOfUse.style.zIndex = "1100"; - termsOfUse.style.bottom = ""; - termsOfUse.className = "olLayerGoogleCopyright olLayerGoogleV3"; - termsOfUse.style.display = ""; - cache.termsOfUse = termsOfUse; - - var poweredBy = div.lastChild; - container.appendChild(poweredBy); - poweredBy.style.zIndex = "1100"; - poweredBy.style.bottom = ""; - poweredBy.className = "olLayerGooglePoweredBy olLayerGoogleV3 gmnoprint"; - poweredBy.style.display = ""; - cache.poweredBy = poweredBy; + // depends on value of zIndex, which is not robust + for (var i=div.children.length-1; i>=0; --i) { + if (div.children[i].style.zIndex == 1000001) { + var termsOfUse = div.children[i]; + container.appendChild(termsOfUse); + termsOfUse.style.zIndex = "1100"; + termsOfUse.style.bottom = ""; + termsOfUse.className = "olLayerGoogleCopyright olLayerGoogleV3"; + termsOfUse.style.display = ""; + cache.termsOfUse = termsOfUse; + } + if (div.children[i].style.zIndex == 1000000) { + var poweredBy = div.children[i]; + container.appendChild(poweredBy); + poweredBy.style.zIndex = "1100"; + poweredBy.style.bottom = ""; + poweredBy.className = "olLayerGooglePoweredBy olLayerGoogleV3 gmnoprint"; + poweredBy.style.display = ""; + cache.poweredBy = poweredBy; + } + if (div.children[i].style.zIndex == 10000002) { + container.appendChild(div.children[i]); + } + } this.setGMapVisibility(this.visibility); 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/Layer/UTFGrid.js b/lib/OpenLayers/Layer/UTFGrid.js index 587047b1ba..b833f60d49 100644 --- a/lib/OpenLayers/Layer/UTFGrid.js +++ b/lib/OpenLayers/Layer/UTFGrid.js @@ -13,7 +13,7 @@ * This Layer reads from UTFGrid tiled data sources. Since UTFGrids are * essentially JSON-based ASCII art with attached attributes, they are not * visibly rendered. In order to use them in the map, you must add a - * ontrol as well. + * control as well. * * Example: * diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index f344a0b7f1..ab2cc1a928 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -83,6 +83,7 @@ OpenLayers.Map = OpenLayers.Class({ * mouseout - triggered after mouseout the map * mousemove - triggered after mousemove the map * changebaselayer - triggered after the base layer changes + * updatesize - triggered after the method was executed */ /** @@ -662,6 +663,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()) { @@ -1489,6 +1491,7 @@ OpenLayers.Map = OpenLayers.Class({ } } + this.events.triggerEvent("updatesize"); }, /** @@ -1783,18 +1786,42 @@ OpenLayers.Map = OpenLayers.Class({ * 's maxExtent. */ adjustZoom: function(zoom) { - var resolution, resolutions = this.baseLayer.resolutions, - maxResolution = this.getMaxExtent().getWidth() / this.size.w; - if (this.getResolutionForZoom(zoom) > maxResolution) { - for (var i=zoom|0, ii=resolutions.length; i maxResolution) { + if (this.fractionalZoom) { + zoom = this.getZoomForResolution(maxResolution); + } else { + for (var i=zoom|0, ii=resolutions.length; i set to true, this will be the + * first zoom level that shows no more than one world width in the current + * map viewport. Components that rely on this value (e.g. zoom sliders) + * should also listen to the map's "updatesize" event and call this method + * in the "updatesize" listener. + * + * Returns: + * {Number} Minimum zoom level that shows a map not wider than its + * 's maxExtent. This is an Integer value, unless the map is + * configured with set to true. + */ + getMinZoom: function() { + return this.adjustZoom(0); + }, /** * Method: moveTo @@ -1817,13 +1844,11 @@ OpenLayers.Map = OpenLayers.Class({ zoom = Math.round(zoom); } } - if (this.baseLayer.wrapDateLine) { - var requestedZoom = zoom; - zoom = this.adjustZoom(zoom); - if (zoom !== requestedZoom) { - // zoom was adjusted, so keep old lonlat to avoid panning - lonlat = this.getCenter(); - } + var requestedZoom = zoom; + zoom = this.adjustZoom(zoom); + if (zoom !== requestedZoom) { + // zoom was adjusted, so keep old lonlat to avoid panning + lonlat = this.getCenter(); } // dragging is false by default var dragging = options.dragging || this.dragging; 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/Renderer/SVG.js b/lib/OpenLayers/Renderer/SVG.js index d2f9fd1b64..85be57989e 100644 --- a/lib/OpenLayers/Renderer/SVG.js +++ b/lib/OpenLayers/Renderer/SVG.js @@ -449,7 +449,7 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, { */ createRenderRoot: function() { var svg = this.nodeFactory(this.container.id + "_svgRoot", "svg"); - svg.style.position = "absolute"; + svg.style.display = "block"; return svg; }, diff --git a/lib/OpenLayers/SingleFile.js b/lib/OpenLayers/SingleFile.js index 53060cc956..ab5401ceb9 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-rc3", + VERSION_NUMBER: "Release 2.12-rc7", /** * Constant: singleFile diff --git a/lib/OpenLayers/Tile/Image.js b/lib/OpenLayers/Tile/Image.js index 50c2548202..abfdf24f39 100644 --- a/lib/OpenLayers/Tile/Image.js +++ b/lib/OpenLayers/Tile/Image.js @@ -339,9 +339,9 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { */ setImgSrc: function(url) { var img = this.imgDiv; - img.style.visibility = 'hidden'; - img.style.opacity = 0; if (url) { + img.style.visibility = 'hidden'; + img.style.opacity = 0; // don't set crossOrigin if the url is a data URL if (this.crossOriginKeyword) { if (url.substr(0, 5) !== 'data:') { @@ -351,6 +351,13 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { } } img.src = url; + } else { + // Remove reference to the image, and leave it to the browser's + // caching and garbage collection. + this.imgDiv = null; + if (img.parentNode) { + img.parentNode.removeChild(img); + } } }, diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index 254f4aa58e..0693b38986 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 @@ -1634,6 +1627,33 @@ OpenLayers.Util.getRenderedDimensions = function(contentHTML, size, options) { var containerElement = (options && options.containerElement) ? options.containerElement : document.body; + + // Opera and IE7 can't handle a node with position:aboslute if it inherits + // position:absolute from a parent. + var parentHasPositionAbsolute = false; + var superContainer = null; + var parent = containerElement; + while (parent && parent.tagName.toLowerCase()!="body") { + var parentPosition = OpenLayers.Element.getStyle(parent, "position"); + if(parentPosition == "absolute") { + parentHasPositionAbsolute = true; + break; + } else if (parentPosition && parentPosition != "static") { + break; + } + parent = parent.parentNode; + } + if(parentHasPositionAbsolute && (containerElement.clientHeight === 0 || + containerElement.clientWidth === 0) ){ + superContainer = document.createElement("div"); + superContainer.style.visibility = "hidden"; + superContainer.style.position = "absolute"; + superContainer.style.overflow = "visible"; + superContainer.style.width = document.body.clientWidth + "px"; + superContainer.style.height = document.body.clientHeight + "px"; + superContainer.appendChild(container); + } + container.style.position = "absolute"; //fix a dimension, if specified. if (size) { @@ -1668,25 +1688,10 @@ OpenLayers.Util.getRenderedDimensions = function(contentHTML, size, options) { container.appendChild(content); // append container to body for rendering - containerElement.appendChild(container); - - // Opera and IE7 can't handle a node with position:aboslute if it inherits - // position:absolute from a parent. - var parentHasPositionAbsolute = false; - var parent = container.parentNode; - while (parent && parent.tagName.toLowerCase()!="body") { - var parentPosition = OpenLayers.Element.getStyle(parent, "position"); - if(parentPosition == "absolute") { - parentHasPositionAbsolute = true; - break; - } else if (parentPosition && parentPosition != "static") { - break; - } - parent = parent.parentNode; - } - - if(!parentHasPositionAbsolute) { - container.style.position = "absolute"; + if (superContainer) { + containerElement.appendChild(superContainer); + } else { + containerElement.appendChild(container); } // calculate scroll width of content and add corners and shadow width @@ -1703,7 +1708,12 @@ OpenLayers.Util.getRenderedDimensions = function(contentHTML, size, options) { // remove elements container.removeChild(content); - containerElement.removeChild(container); + if (superContainer) { + superContainer.removeChild(container); + containerElement.removeChild(superContainer); + } else { + containerElement.removeChild(container); + } return new OpenLayers.Size(w, h); }; 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..1cb4aab675 100644 --- a/notes/2.12.md +++ b/notes/2.12.md @@ -25,6 +25,16 @@ Corresponding issues/pull requests: * https://github.com/openlayers/openlayers/pull/254 * https://github.com/openlayers/openlayers/pull/261 +## style.mobile.css + +The theme/default directory now includes a mobile-specific CSS file, namely +style.mobile.css. The OpenLayers mobile examples use this file. To use it +in your mobile pages use tags like this: + + + +(This file used to be in the examples/ directory). + ## Sensible projection defaults The geographic and web mercator projections define default values for the maxExtent, and units. This simplifies the map and layer configuration. @@ -219,6 +229,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/Control/PanZoomBar.html b/tests/Control/PanZoomBar.html index 852c00f4df..b14ec2adba 100644 --- a/tests/Control/PanZoomBar.html +++ b/tests/Control/PanZoomBar.html @@ -33,6 +33,31 @@ map.addControl(control2, new OpenLayers.Pixel(100,100)); t.eq( control2.div.style.top, "100px", "2nd control div is located correctly"); } + + function test_draw(t) { + t.plan(3); + map = new OpenLayers.Map('map', {controls:[]}); + var layer = new OpenLayers.Layer.WMS("Test Layer", + "http://octo.metacarta.com/cgi-bin/mapserv?", + {map: "/mapdata/vmap_wms.map", layers: "basic"}); + map.addLayer(layer); + map.zoomToMaxExtent(); + control = new OpenLayers.Control.PanZoomBar(); + map.addControl(control); + t.eq(control.zoombarDiv.style.height, '176px', "Bar's height is correct."); + + map.baseLayer.wrapDateLine = true; + + control.redraw(); + t.eq(control.zoombarDiv.style.height, '154px', "Bar's height is correct after minZoom restriction."); + + map.div.style.width = "512px"; + map.updateSize(); + t.eq(control.zoombarDiv.style.height, '165px', "Bar's height is correct after resize and minZoom restriction."); + + map.div.style.width = "1024px"; + map.destroy(); + } function test_Control_PanZoomBar_clearDiv(t) { t.plan(2); diff --git a/tests/Control/SelectFeature.html b/tests/Control/SelectFeature.html index 68e3031165..150ab07c5c 100644 --- a/tests/Control/SelectFeature.html +++ b/tests/Control/SelectFeature.html @@ -558,6 +558,46 @@ t.eq(layer1.renderer.getRenderLayerId(), layer1.id, "Root container moved correctly when control is destroyed and layers was an array parameter"); } + + function test_unselectAll(t) { + t.plan(2); + + var layer = new OpenLayers.Layer.Vector(); + + var control = new OpenLayers.Control.SelectFeature(layer); + + var feature1 = new OpenLayers.Feature.Vector(); + feature1.id = 1; + var feature2 = new OpenLayers.Feature.Vector(); + feature2.id = 2; + var feature3 = new OpenLayers.Feature.Vector(); + feature3.id = 3; + var feature4 = new OpenLayers.Feature.Vector(); + feature4.id = 4; + + layer.addFeatures([feature1, feature2, feature3, feature4]); + + control.select(feature1); + control.select(feature2); + control.select(feature3); + control.select(feature4); + + layer.events.on({ + featureunselected: function(e) { + // we change the selectedFeatures array while + // unselectAll is iterating over that array. + if(feature2.layer) { + layer.removeFeatures([feature2]); + } + } + }); + + control.unselectAll({except: feature3}); + t.eq(layer.selectedFeatures.length, 1, + 'unselectAll unselected all but one'); + t.eq(layer.selectedFeatures[0].id, 3, + 'the remaining selected features is the one expected'); + } diff --git a/tests/Control/Split.html b/tests/Control/Split.html index 86af76c56d..e3a6eacecf 100644 --- a/tests/Control/Split.html +++ b/tests/Control/Split.html @@ -104,13 +104,18 @@ t.plan(7); - var layer = new OpenLayers.Layer.Vector("foo", { + var layer1 = new OpenLayers.Layer.Vector("foo", { maxExtent: new OpenLayers.Bounds(-10, -10, 10, 10), isBaseLayer: true }); - var control = new OpenLayers.Control.Split({layer: layer}); + var layer2 = new OpenLayers.Layer.Vector("bar", { + maxExtent: new OpenLayers.Bounds(-10, -10, 10, 10), + isBaseLayer: false + }); + var control = new OpenLayers.Control.Split({layer: layer1}); var map = new OpenLayers.Map("map"); - map.addLayer(layer); + map.addLayer(layer1); + map.addLayer(layer2); map.zoomToMaxExtent(); map.addControl(control); @@ -124,17 +129,17 @@ t.eq(control.handler.active, false, "sketch handler deactivated"); // set a source layer - control.setSource(layer); + control.setSource(layer2); // activate and check that listeners are registered control.activate(); - t.ok(layer.events.listeners.sketchcomplete, "sketchcomplete listener registered"); - t.ok(layer.events.listeners.afterfeaturemodified, "afterfeaturemodified listener registered"); + t.ok(layer2.events.listeners.sketchcomplete, "sketchcomplete listener registered"); + t.ok(layer2.events.listeners.afterfeaturemodified, "afterfeaturemodified listener registered"); // deactivate and confirm no draw related events control.deactivate(); - t.eq(layer.events.listeners.sketchcomplete.length, 0, "no sketchcomplete listeners"); - t.eq(layer.events.listeners.afterfeaturemodified.length, 0, "no afterfeaturemodified listeners"); + t.eq(layer2.events.listeners.sketchcomplete.length, 0, "no sketchcomplete listeners"); + t.eq(layer2.events.listeners.afterfeaturemodified.length, 0, "no afterfeaturemodified listeners"); map.destroy(); } diff --git a/tests/Control/ZoomBox.html b/tests/Control/ZoomBox.html new file mode 100644 index 0000000000..2e037192e5 --- /dev/null +++ b/tests/Control/ZoomBox.html @@ -0,0 +1,52 @@ + + + + + + + +
+ + diff --git a/tests/Format/GML/cases.js b/tests/Format/GML/cases.js index 258c570416..88499cdc3d 100644 --- a/tests/Format/GML/cases.js +++ b/tests/Format/GML/cases.js @@ -198,14 +198,19 @@ var cases = { ]) ]) ]), - + "v2/box-coord.xml": new OpenLayers.Bounds(1, 2, 3, 4), - "v2/box-coordinates.xml": new OpenLayers.Bounds(1, 2, 3, 4) + "v2/box-coordinates.xml": new OpenLayers.Bounds(1, 2, 3, 4), + + "v3/linestring3d.xml": new OpenLayers.Geometry.LineString([ + new OpenLayers.Geometry.Point(1, 2, 3), + new OpenLayers.Geometry.Point(4, 5, 6) + ]) }; -// cases for v3 use the same geometries +// some cases for v3 use the same geometries OpenLayers.Util.extend(cases, { "v3/point.xml": cases["v2/point-coordinates.xml"], "v3/linestring.xml": cases["v2/linestring-coordinates.xml"], diff --git a/tests/Format/GML/v3.html b/tests/Format/GML/v3.html index 9e6c5b8482..92f2154917 100644 --- a/tests/Format/GML/v3.html +++ b/tests/Format/GML/v3.html @@ -10,8 +10,8 @@ "v2/linestring-coord.xml", "v2/linestring-coordinates.xml", "v2/multipoint-coord.xml", "v2/multipoint-coordinates.xml", "v2/multilinestring-coord.xml", "v2/multilinestring-coordinates.xml", - "v3/point.xml", "v3/linestring.xml", "v3/curve.xml", - "v3/polygon.xml", "v3/surface.xml", + "v3/point.xml", "v3/linestring.xml", "v3/linestring3d.xml", + "v3/curve.xml", "v3/polygon.xml", "v3/surface.xml", "v3/multipoint-singular.xml", "v3/multipoint-plural.xml", "v3/multilinestring-singular.xml", "v3/multilinestring-plural.xml", "v3/multicurve-singular.xml", "v3/multicurve-curve.xml", @@ -332,6 +332,11 @@ 1 2 3 4 -->
+