From 1a1cb9fe4e1b70b3a09faa936122dc7d0d85697c Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Wed, 25 Jan 2012 16:25:36 +0100 Subject: [PATCH 01/91] Add OpenLayers/Spherical.js --- lib/OpenLayers/Spherical.js | 59 +++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 lib/OpenLayers/Spherical.js diff --git a/lib/OpenLayers/Spherical.js b/lib/OpenLayers/Spherical.js new file mode 100644 index 0000000000..ed64c844f8 --- /dev/null +++ b/lib/OpenLayers/Spherical.js @@ -0,0 +1,59 @@ +/* Copyright (c) 2006-2012 by OpenLayers Contributors (see authors.txt for + * full list of contributors). Published under the Clear BSD license. + * See http://svn.openlayers.org/trunk/openlayers/license.txt for the + * full text of the license. */ + +/** + * @see http://www.movable-type.co.uk/scripts/latlong.html + * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#spherical + */ + + +/** + * Namespace: Spherical + */ +OpenLayers.Spherical = OpenLayers.Spherical || {}; + + +OpenLayers.Spherical.DEFAULT_RADIUS = 6378137; + + +/** + * APIFunction: computeDistanceBetween + * Computes the distance between two LonLats. + * + * Parameters: + * from - {} + * to - {} + * radius - {Float} + * + * Returns: + * {Float} The distance in meters. + */ +OpenLayers.Spherical.computeDistanceBetween = function(from, to, radius) { + var R = radius || OpenLayers.Spherical.DEFAULT_RADIUS; + var sinHalfDeltaLon = Math.sin(Math.PI * (to.lon - from.lon) / 360); + var sinHalfDeltaLat = Math.sin(Math.PI * (to.lat - from.lat) / 360); + var a = sinHalfDeltaLat * sinHalfDeltaLat + + sinHalfDeltaLon * sinHalfDeltaLon * Math.cos(Math.PI * from.lat / 180) * Math.cos(Math.PI * to.lat / 180); + return 2 * R * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); +}; + + +/** + * APIFunction: computeHeading + * Computes the heading from one LonLat to another LonLat. + * + * Parameters: + * from - {} + * to - {} + * + * Returns: + * {Float} The heading in degrees. + */ +OpenLayers.Spherical.computeHeading = function(from, to) { + var y = Math.sin(Math.PI * (from.lon - to.lon) / 180) * Math.cos(Math.PI * to.lat / 180); + var x = Math.cos(Math.PI * from.lat / 180) * Math.sin(Math.PI * to.lat / 180) - + Math.sin(Math.PI * from.lat / 180) * Math.cos(Math.PI * to.lat / 180) * Math.cos(Math.PI * (from.lon - to.lon) / 180); + return 180 * Math.atan2(y, x) / Math.PI; +}; From ef85f43d21e58f7a8d840e091097b0e10dffa82c Mon Sep 17 00:00:00 2001 From: ahocevar Date: Thu, 26 Jan 2012 01:24:11 +0100 Subject: [PATCH 02/91] A tile queue that can be aborted. This saves server requests, and because we use OpenLayers.Animation, setting img.src on a tile should not freeze iOS any more, so we can hopefully get rid of scheduleMoveGriddedTiles. --- examples/mobile-wmts-vienna.html | 3 +- examples/mobile-wmts-vienna.js | 2 - lib/OpenLayers/Layer/Grid.js | 274 ++++++++---------- tests/Layer/ArcGIS93Rest.html | 5 + tests/Layer/Grid.html | 19 +- tests/Layer/MapServer.html | 5 + tests/Layer/WMS.html | 5 + tests/Layer/WrapDateLine.html | 5 + tests/deprecated/Layer/MapServer/Untiled.html | 5 + 9 files changed, 165 insertions(+), 158 deletions(-) diff --git a/examples/mobile-wmts-vienna.html b/examples/mobile-wmts-vienna.html index 280f66ce74..11e1ee995e 100644 --- a/examples/mobile-wmts-vienna.html +++ b/examples/mobile-wmts-vienna.html @@ -6,8 +6,8 @@ + -

City of Vienna WMTS for Desktop and Mobile Devices

@@ -22,6 +22,7 @@ functionality and uses the Geolocate control.

+ diff --git a/examples/mobile-wmts-vienna.js b/examples/mobile-wmts-vienna.js index 692b86afe2..4257f7429b 100644 --- a/examples/mobile-wmts-vienna.js +++ b/examples/mobile-wmts-vienna.js @@ -152,7 +152,6 @@ var map; var defaults = { requestEncoding: "REST", matrixSet: "google3857", - buffer: 4, attribution: 'Datenquelle: Stadt Wien - data.wien.gv.at' }; var doc = request.responseText, @@ -182,7 +181,6 @@ var map; requestEncoding: "REST", matrixSet: "google3857", tileFullExtent: extent, - buffer: 4, attribution: 'Datenquelle: Stadt Wien - data.wien.gv.at' }; fmzk = new OpenLayers.Layer.WMTS(OpenLayers.Util.applyDefaults({ diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index 0a1c2d8220..1e5b0c9d89 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -97,13 +97,6 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { */ numLoadingTiles: 0, - /** - * APIProperty: tileLoadingDelay - * {Integer} - Number of milliseconds before we shift and load - * tiles. Default is 100. - */ - tileLoadingDelay: 100, - /** * Property: serverResolutions * {Array(Number}} This property is documented in subclasses as @@ -112,10 +105,16 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { serverResolutions: null, /** - * Property: timerId - * {Number} - The id of the tileLoadingDelay timer. + * Property: tileLoopId + * {Number} - The id of the animation. */ - timerId: null, + tileLoopId: null, + + /** + * Property: tileOperations + * {Array(Object)} Pending tile operations. + */ + tileOperations: null, /** * Property: backBuffer @@ -152,7 +151,7 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { * flash effects caused by tile animation. */ backBufferTimerId: null, - + /** * Register a listener for a particular event with the following syntax: * (code) @@ -187,10 +186,7 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { OpenLayers.Layer.HTTPRequest.prototype.initialize.apply(this, arguments); this.grid = []; - - this._moveGriddedTiles = OpenLayers.Function.bind( - this.moveGriddedTiles, this - ); + this.tileOperations = []; }, /** @@ -201,10 +197,7 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { * map - {} The map. */ removeMap: function(map) { - if(this.timerId != null) { - window.clearTimeout(this.timerId); - this.timerId = null; - } + this.abortTileOperations(); if(this.backBufferTimerId !== null) { window.clearTimeout(this.backBufferTimerId); this.backBufferTimerId = null; @@ -230,20 +223,20 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { * destroy() on each of them to kill circular references */ clearGrid:function() { + this.abortTileOperations(); if (this.grid) { for(var iRow=0, len=this.grid.length; iRow} + */ + destroyTile: function(tile) { + for (var i=this.tileOperations.length-1; i>=0; --i) { + if (this.tileOperations[i].scope === tile) { + this.tileOperations.splice(i, 1); + } + } + this.removeTileMonitoringHooks(tile); + tile.destroy(); + }, /** * Method: getServerResolution @@ -565,24 +619,10 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { */ moveByPx: function(dx, dy) { if (!this.singleTile) { - this.scheduleMoveGriddedTiles(); + this.moveGriddedTiles(); } }, - /** - * Method: scheduleMoveGriddedTiles - * Schedule the move of tiles. - */ - scheduleMoveGriddedTiles: function() { - if (this.timerId != null) { - window.clearTimeout(this.timerId); - } - this.timerId = window.setTimeout( - this._moveGriddedTiles, - this.tileLoadingDelay - ); - }, - /** * APIMethod: setTileSize * Check if we are in singleTile mode and if so, set the size as a ratio @@ -776,7 +816,7 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { var layerContainerDivLeft = parseInt(this.map.layerContainerDiv.style.left); var layerContainerDivTop = parseInt(this.map.layerContainerDiv.style.top); - + var tileData = [], center = this.map.getCenter(); do { var row = this.grid[rowidx++]; if (!row) { @@ -810,6 +850,12 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { } else { tile.moveTo(tileBounds, px, false); } + var tileCenter = tileBounds.getCenterLonLat(); + tileData.push({ + tile: tile, + distance: Math.pow(tileCenter.lon - center.lon, 2) + + Math.pow(tileCenter.lat - center.lat, 2) + }); tileoffsetlon += tilelon; tileoffsetx += this.tileSize.w; @@ -828,7 +874,12 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { this.gridResolution = this.getServerResolution(); //now actually draw the tiles - this.spiralTileLoad(); + tileData.sort(function(a, b) { + return a.distance - b.distance; + }); + for (var i=0, ii=tileData.length; i= 0) && - (testCell < this.grid[0].length) && (testCell >= 0)) { - tile = this.grid[testRow][testCell]; - } - - if ((tile != null) && (!tile.queued)) { - //add tile to beginning of queue, mark it as queued. - tileQueue.unshift(tile); - tile.queued = true; - - //restart the directions counter and take on the new coords - directionsTried = 0; - iRow = testRow; - iCell = testCell; - } else { - //need to try to load a tile in a different direction - direction = (direction + 1) % 4; - directionsTried++; - } - } - - // now we go through and draw the tiles in forward order - for(var i=0, len=tileQueue.length; i} The added OpenLayers.Tile */ addTile: function(bounds, position) { + var that = this; + var options = OpenLayers.Util.extend({ + draw: function() { + // clear immediately + this.clear(); + // draw in an animation frame - can be aborted + that.addTileOperation(that.tileClass.prototype.draw, this); + } + }, this.tileOptions); return new this.tileClass(this, position, bounds, null, - this.tileSize, this.tileOptions); + this.tileSize, options); }, /** @@ -993,37 +980,32 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { * Method: moveGriddedTiles */ moveGriddedTiles: function() { - var shifted = true; var buffer = this.buffer || 1; var scale = this.getResolutionScale(); - var tlLayer = this.grid[0][0].position.clone(); - tlLayer.x *= scale; - tlLayer.y *= scale; - tlLayer = tlLayer.add(parseInt(this.div.style.left, 10), - parseInt(this.div.style.top, 10)); - var offsetX = parseInt(this.map.layerContainerDiv.style.left); - var offsetY = parseInt(this.map.layerContainerDiv.style.top); - var tlViewPort = tlLayer.add(offsetX, offsetY); - var tileSize = { - w: this.tileSize.w * scale, - h: this.tileSize.h * scale - }; - if (tlViewPort.x > -tileSize.w * (buffer - 1)) { - this.shiftColumn(true); - } else if (tlViewPort.x < -tileSize.w * buffer) { - this.shiftColumn(false); - } else if (tlViewPort.y > -tileSize.h * (buffer - 1)) { - this.shiftRow(true); - } else if (tlViewPort.y < -tileSize.h * buffer) { - this.shiftRow(false); - } else { - shifted = false; - } - if (shifted) { - // we may have other row or columns to shift, schedule it - // with a setTimeout, to give the user a chance to sneak - // in moveTo's - this.timerId = window.setTimeout(this._moveGriddedTiles, 0); + while(true) { + var tlLayer = this.grid[0][0].position.clone(); + tlLayer.x *= scale; + tlLayer.y *= scale; + tlLayer = tlLayer.add(parseInt(this.div.style.left, 10), + parseInt(this.div.style.top, 10)); + var offsetX = parseInt(this.map.layerContainerDiv.style.left); + var offsetY = parseInt(this.map.layerContainerDiv.style.top); + var tlViewPort = tlLayer.add(offsetX, offsetY); + var tileSize = { + w: this.tileSize.w * scale, + h: this.tileSize.h * scale + }; + if (tlViewPort.x > -tileSize.w * (buffer - 1)) { + this.shiftColumn(true); + } else if (tlViewPort.x < -tileSize.w * buffer) { + this.shiftColumn(false); + } else if (tlViewPort.y > -tileSize.h * (buffer - 1)) { + this.shiftRow(true); + } else if (tlViewPort.y < -tileSize.h * buffer) { + this.shiftRow(false); + } else { + break; + } } }, @@ -1113,8 +1095,7 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { var row = this.grid.pop(); for (var i=0, l=row.length; iwindow.alert = oldAlert; From d72b5b4810f1da859bb9285be0da286f3adc9471 Mon Sep 17 00:00:00 2001 From: fredj Date: Fri, 3 Feb 2012 12:37:53 +0100 Subject: [PATCH 13/91] Remove OpenLayers.Protocol.CSW.v2_0_2.createCallback, already defined in OpenLayers.Protocol --- lib/OpenLayers/Protocol/CSW/v2_0_2.js | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/lib/OpenLayers/Protocol/CSW/v2_0_2.js b/lib/OpenLayers/Protocol/CSW/v2_0_2.js index 74418f3acd..b701966653 100644 --- a/lib/OpenLayers/Protocol/CSW/v2_0_2.js +++ b/lib/OpenLayers/Protocol/CSW/v2_0_2.js @@ -52,23 +52,6 @@ OpenLayers.Protocol.CSW.v2_0_2 = OpenLayers.Class(OpenLayers.Protocol, { OpenLayers.Protocol.prototype.destroy.apply(this); }, - /** - * Method: createCallback - * Returns a function that applies the given public method with resp and - * options arguments. - * - * Parameters: - * method - {Function} The method to be applied by the callback. - * response - {} The protocol response object. - * options - {Object} Options sent to the protocol method (read, create, - * update, or delete). - */ - createCallback: function(method, response, options) { - return OpenLayers.Function.bind(function() { - method.apply(this, [response, options]); - }, this); - }, - /** * Method: read * Construct a request for reading new records from the Catalogue. From 0d27dc82aeb46f6583bf9931bc54715ab9723051 Mon Sep 17 00:00:00 2001 From: Antoine Abt Date: Mon, 6 Feb 2012 21:41:08 +0100 Subject: [PATCH 14/91] re-add default labelAlign, but avoid duplicate declaration accross renderers --- lib/OpenLayers/Renderer.js | 3 ++- lib/OpenLayers/Renderer/SVG.js | 2 +- lib/OpenLayers/Renderer/SVG2.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/OpenLayers/Renderer.js b/lib/OpenLayers/Renderer.js index a843edd178..45de3a6f3f 100644 --- a/lib/OpenLayers/Renderer.js +++ b/lib/OpenLayers/Renderer.js @@ -411,6 +411,7 @@ OpenLayers.Renderer.defaultSymbolizer = { strokeWidth: 2, fillOpacity: 1, strokeOpacity: 1, - pointRadius: 0 + pointRadius: 0, + labelAlign: 'cm' }; diff --git a/lib/OpenLayers/Renderer/SVG.js b/lib/OpenLayers/Renderer/SVG.js index 42a72e855b..dfd345553d 100644 --- a/lib/OpenLayers/Renderer/SVG.js +++ b/lib/OpenLayers/Renderer/SVG.js @@ -696,7 +696,7 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, { } else { label.setAttributeNS(null, "pointer-events", "none"); } - var align = style.labelAlign; + var align = style.labelAlign || OpenLayers.Renderer.defaultSymbolizer.labelAlign; label.setAttributeNS(null, "text-anchor", OpenLayers.Renderer.SVG.LABEL_ALIGN[align[0]] || "middle"); diff --git a/lib/OpenLayers/Renderer/SVG2.js b/lib/OpenLayers/Renderer/SVG2.js index a385689481..3f64c50ca8 100644 --- a/lib/OpenLayers/Renderer/SVG2.js +++ b/lib/OpenLayers/Renderer/SVG2.js @@ -584,7 +584,7 @@ OpenLayers.Renderer.SVG2 = OpenLayers.Class(OpenLayers.Renderer.NG, { } else { text.setAttributeNS(null, "pointer-events", "none"); } - var align = style.labelAlign; + var align = style.labelAlign || OpenLayers.Renderer.defaultSymbolizer.labelAlign; text.setAttributeNS(null, "text-anchor", OpenLayers.Renderer.SVG2.LABEL_ALIGN[align[0]] || "middle"); From 00a00db127960cadf38967240d777d92333da17f Mon Sep 17 00:00:00 2001 From: Peter Robins Date: Tue, 7 Feb 2012 11:57:29 +0000 Subject: [PATCH 15/91] ReadWithPOST should pass through options.headers --- lib/OpenLayers/Protocol/HTTP.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Protocol/HTTP.js b/lib/OpenLayers/Protocol/HTTP.js index edcb3ed6fa..ebfacac705 100644 --- a/lib/OpenLayers/Protocol/HTTP.js +++ b/lib/OpenLayers/Protocol/HTTP.js @@ -166,7 +166,7 @@ OpenLayers.Protocol.HTTP = OpenLayers.Class(OpenLayers.Protocol, { * {} A response object, whose "priv" property * references the HTTP request, this object is also passed to the * callback function when the request completes, its "features" property - * is then populated with the the features received from the server. + * is then populated with the features received from the server. */ read: function(options) { OpenLayers.Protocol.prototype.read.apply(this, arguments); @@ -183,13 +183,13 @@ OpenLayers.Protocol.HTTP = OpenLayers.Class(OpenLayers.Protocol, { options.readWithPOST : this.readWithPOST; var resp = new OpenLayers.Protocol.Response({requestType: "read"}); if(readWithPOST) { + var headers = options.headers || {}; + headers["Content-Type"] = "application/x-www-form-urlencoded"; resp.priv = OpenLayers.Request.POST({ url: options.url, callback: this.createCallback(this.handleRead, resp, options), data: OpenLayers.Util.getParameterString(options.params), - headers: { - "Content-Type": "application/x-www-form-urlencoded" - } + headers: headers }); } else { resp.priv = OpenLayers.Request.GET({ From 92f8040938b39e4b8ae9e332622ed559fd9e23c0 Mon Sep 17 00:00:00 2001 From: Pierre GIRAUD Date: Wed, 8 Feb 2012 10:39:31 +0100 Subject: [PATCH 16/91] More up-to-date way to create or set namespacedj elements or attributes. --- lib/OpenLayers/Format/GPX.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/OpenLayers/Format/GPX.js b/lib/OpenLayers/Format/GPX.js index 401321519a..f3f0fce313 100644 --- a/lib/OpenLayers/Format/GPX.js +++ b/lib/OpenLayers/Format/GPX.js @@ -218,12 +218,11 @@ OpenLayers.Format.GPX = OpenLayers.Class(OpenLayers.Format.XML, { write: function(features, metadata) { features = OpenLayers.Util.isArray(features) ? features : [features]; - var gpx = this.createElementNS(this.namespaces["gpx"], "gpx"); + var gpx = this.createElementNSPlus("gpx:gpx"); gpx.setAttribute("version", "1.1"); - this.setAttributeNS( - gpx, this.namespaces["xsi"], - "xsi:schemaLocation", this.schemaLocation - ); + this.setAttributes(gpx, { + "xsi:schemaLocation": this.schemaLocation + }); if (metadata && typeof metadata == 'object') { gpx.appendChild(this.buildMetadataNode(metadata)); @@ -243,11 +242,11 @@ OpenLayers.Format.GPX = OpenLayers.Class(OpenLayers.Format.XML, { */ buildMetadataNode: function(metadata) { var types = ['name', 'desc', 'author'], - node = this.createElementNS(this.namespaces["gpx"], 'metadata'); + node = this.createElementNSPlus('gpx:metadata'); for (var i=0; i < types.length; i++) { var type = types[i]; if (metadata[type]) { - var n = this.createElementNS(this.namespaces["gpx"], type); + var n = this.createElementNSPlus("gpx:" + type); n.appendChild(this.createTextNode(metadata[type])); node.appendChild(n); } @@ -276,7 +275,7 @@ OpenLayers.Format.GPX = OpenLayers.Class(OpenLayers.Format.XML, { var wpt = this.buildWptNode(feature); return wpt; } else { - var trkNode = this.createElementNS(this.namespaces["gpx"], "trk"); + var trkNode = this.createElementNSPlus("gpx:trk"); this.appendAttributesNode(trkNode, feature); var trkSegNodes = this.buildTrkSegNode(geometry); trkSegNodes = OpenLayers.Util.isArray(trkSegNodes) ? @@ -304,7 +303,7 @@ OpenLayers.Format.GPX = OpenLayers.Class(OpenLayers.Format.XML, { nodes; if (geometry.CLASS_NAME == "OpenLayers.Geometry.LineString" || geometry.CLASS_NAME == "OpenLayers.Geometry.LinearRing") { - node = this.createElementNS(this.namespaces["gpx"], "trkseg"); + node = this.createElementNSPlus("gpx:trkseg"); for (i = 0, len=geometry.components.length; i < len; i++) { point = geometry.components[i]; node.appendChild(this.buildTrkPtNode(point)); @@ -330,7 +329,7 @@ OpenLayers.Format.GPX = OpenLayers.Class(OpenLayers.Format.XML, { * {DOMElement} A trkpt node */ buildTrkPtNode: function(point) { - var node = this.createElementNS(this.namespaces["gpx"], "trkpt"); + var node = this.createElementNSPlus("gpx:trkpt"); node.setAttribute("lon", point.x); node.setAttribute("lat", point.y); return node; @@ -347,7 +346,7 @@ OpenLayers.Format.GPX = OpenLayers.Class(OpenLayers.Format.XML, { * {DOMElement} A wpt node */ buildWptNode: function(feature) { - var node = this.createElementNS(this.namespaces["gpx"], "wpt"); + var node = this.createElementNSPlus("gpx:wpt"); node.setAttribute("lon", feature.geometry.x); node.setAttribute("lat", feature.geometry.y); this.appendAttributesNode(node, feature); @@ -363,11 +362,11 @@ OpenLayers.Format.GPX = OpenLayers.Class(OpenLayers.Format.XML, { * feature - {} */ appendAttributesNode: function(node, feature) { - var name = this.createElementNS(this.namespaces["gpx"], 'name'); + var name = this.createElementNSPlus('gpx:name'); name.appendChild(this.createTextNode( feature.attributes.name || feature.id)); node.appendChild(name); - var desc = this.createElementNS(this.namespaces["gpx"], 'desc'); + var desc = this.createElementNSPlus('gpx:desc'); desc.appendChild(this.createTextNode( feature.attributes.description || this.defaultDesc)); node.appendChild(desc); From 734f150f4f3cd3c67d665ce4411218b3855eaafe Mon Sep 17 00:00:00 2001 From: Pierre GIRAUD Date: Wed, 8 Feb 2012 10:50:38 +0100 Subject: [PATCH 17/91] Adding behavior change node --- notes/2.12.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/notes/2.12.md b/notes/2.12.md index ee5ae8843c..eaf6985f3d 100644 --- a/notes/2.12.md +++ b/notes/2.12.md @@ -22,6 +22,10 @@ People can override this rule to use other transition settings. To remove tile a # Behavior Changes from Past Releases +## GPX API change + +The `gpxns` API property has been removed. The GPX namespace is now defined in the `namespaces` property but is not intended to be overriden. + ## Function return values [Previously][prev] a few functions in the library displayed error messages and returned `undefined`, `null` or `false` if the parameters passed in were bad. In 2.12 these functions now just throw an error/exception. People relying on return values to know if a function call is successful may need to change their code. Here are the modified functions: From e9ffef03c7442b165c8cd4dd3bd668485242d359 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Thu, 9 Feb 2012 10:33:24 +0100 Subject: [PATCH 18/91] create APIMethod for obtaining the view port, this is needed by GeoExt to append the map panel items there so that they don't interfere with the zoombox for example --- lib/OpenLayers/Map.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index b8e976851c..f96ac6f834 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -612,6 +612,17 @@ OpenLayers.Map = OpenLayers.Class({ } } }, + + /** + * APIMethod: getViewport + * Get the DOMElement representing the view port. + * + * Returns: + * {DOMElement} + */ + getViewport: function() { + return this.viewPortDiv; + }, /** * APIMethod: render From 6daecd677d4b0893c906620b74a59b0053e88907 Mon Sep 17 00:00:00 2001 From: fredj Date: Thu, 9 Feb 2012 13:43:42 +0100 Subject: [PATCH 19/91] New createVertices option for Control.ModifyFeature --- examples/modify-feature.html | 6 ++++++ lib/OpenLayers/Control/ModifyFeature.js | 9 ++++++++- tests/Control/ModifyFeature.html | 19 +++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/examples/modify-feature.html b/examples/modify-feature.html index 8cec2306af..cb19858ddd 100644 --- a/examples/modify-feature.html +++ b/examples/modify-feature.html @@ -96,6 +96,7 @@ if (rotate || drag) { controls.modify.mode &= ~OpenLayers.Control.ModifyFeature.RESHAPE; } + controls.modify.createVertices = document.getElementById("createVertices").checked; var sides = parseInt(document.getElementById("sides").value); sides = Math.max(3, isNaN(sides) ? 0 : sides); controls.regular.handler.sides = sides; @@ -161,6 +162,11 @@ onclick="toggleControl(this);" />
    +
  • + + +
  • diff --git a/lib/OpenLayers/Control/ModifyFeature.js b/lib/OpenLayers/Control/ModifyFeature.js index 009bbf242f..6e78184efc 100644 --- a/lib/OpenLayers/Control/ModifyFeature.js +++ b/lib/OpenLayers/Control/ModifyFeature.js @@ -137,6 +137,13 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, { */ mode: null, + /** + * APIProperty: createVertices + * {Boolean} Create new vertices by dragging the virtual vertices + * in the middle of each edge. Default is true. + */ + createVertices: true, + /** * Property: modified * {Boolean} The currently selected feature has been modified. @@ -677,7 +684,7 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, { } // add virtual vertices in the middle of each edge - if(geometry.CLASS_NAME != "OpenLayers.Geometry.MultiPoint") { + if (control.createVertices && geometry.CLASS_NAME != "OpenLayers.Geometry.MultiPoint") { for(i=0, len=geometry.components.length; i From 14624cb8150005815924fae8aedb6b2d520d05e2 Mon Sep 17 00:00:00 2001 From: fredj Date: Wed, 18 Jan 2012 14:03:25 +0100 Subject: [PATCH 20/91] New OpenLayers.CANVAS_SUPPORTED constant --- lib/OpenLayers/Renderer/Canvas.js | 3 +-- lib/OpenLayers/Util.js | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Renderer/Canvas.js b/lib/OpenLayers/Renderer/Canvas.js index 4edaf92a7b..daf9e19e35 100644 --- a/lib/OpenLayers/Renderer/Canvas.js +++ b/lib/OpenLayers/Renderer/Canvas.js @@ -110,8 +110,7 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, { * {Boolean} Whether or not the browser supports the renderer class */ supported: function() { - var canvas = document.createElement("canvas"); - return !!canvas.getContext; + return OpenLayers.CANVAS_SUPPORTED; }, /** diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index 2458a54b67..5ca8c35201 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -1435,6 +1435,15 @@ OpenLayers.IS_GECKO = (function() { return ua.indexOf("webkit") == -1 && ua.indexOf("gecko") != -1; })(); +/** + * Constant: CANVAS_SUPPORTED + * {Boolean} True if canvas 2d is supported. + */ +OpenLayers.CANVAS_SUPPORTED = (function() { + var elem = document.createElement('canvas'); + return !!(elem.getContext && elem.getContext('2d')); +})(); + /** * Constant: BROWSER_NAME * {String} From 57ae02f3812280d25f521f4f4ba9dc1e358e4a79 Mon Sep 17 00:00:00 2001 From: fredj Date: Wed, 18 Jan 2012 14:06:01 +0100 Subject: [PATCH 21/91] Set image.crossOrigin attribute in OpenLayers.Tile.Image --- lib/OpenLayers/Tile/Image.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/OpenLayers/Tile/Image.js b/lib/OpenLayers/Tile/Image.js index 23a7c9668a..28dab38773 100644 --- a/lib/OpenLayers/Tile/Image.js +++ b/lib/OpenLayers/Tile/Image.js @@ -297,6 +297,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { } else { OpenLayers.Event.observe(img, "load", load); OpenLayers.Event.observe(img, "error", load); + img.crossOrigin = null; img.src = this.blankImageUrl; } } @@ -314,6 +315,8 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { img.style.visibility = 'hidden'; img.style.opacity = 0; if (url) { + // don't set crossOrigin if the url is a data URL + img.crossOrigin = url.indexOf('data:') === 0 ? null : ''; img.src = url; } }, From b4ac0af5d86e51f9c317e7546a0e3865b1f06417 Mon Sep 17 00:00:00 2001 From: fredj Date: Wed, 18 Jan 2012 14:06:22 +0100 Subject: [PATCH 22/91] New OpenLayers.Tile.Image.getCanvasContext function --- lib/OpenLayers/Tile/Image.js | 32 ++++++++++++++++++++++++++++++++ tests/Tile/Image.html | 25 +++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/lib/OpenLayers/Tile/Image.js b/lib/OpenLayers/Tile/Image.js index 28dab38773..7baf8bf98e 100644 --- a/lib/OpenLayers/Tile/Image.js +++ b/lib/OpenLayers/Tile/Image.js @@ -81,6 +81,13 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { */ maxGetUrlLength: null, + /** + * Property: canvasContext + * {CanvasRenderingContext2D} A canvas context associated with + * the tile image. + */ + canvasContext: null, + /** TBD 3.0 - reorder the parameters to the init function to remove * URL. the getUrl() function on the layer gets called on * each draw(), so no need to specify it here. @@ -216,6 +223,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { } OpenLayers.Element.removeClass(img, "olImageLoadError"); } + this.canvasContext = null; }, /** @@ -369,6 +377,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { img.style.opacity = this.layer.opacity; this.isLoading = false; + this.canvasContext = null; this.events.triggerEvent("loadend"); // IE<7 needs a reflow when the tiles are loaded because of the @@ -409,6 +418,29 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { } }, + /** + * APIMethod: getCanvasContext + * Returns a canvas context associated with the tile image (with + * the image drawn on it). + * Returns undefined if the browser does not support canvas, if + * the tile has no image or if it's currently loading. + * + * Returns: + * {Boolean} + */ + getCanvasContext: function() { + if (OpenLayers.CANVAS_SUPPORTED && this.imgDiv && !this.isLoading) { + if (!this.canvasContext) { + var canvas = document.createElement("canvas"); + canvas.width = this.size.w; + canvas.height = this.size.h; + this.canvasContext = canvas.getContext("2d"); + this.canvasContext.drawImage(this.imgDiv, 0, 0); + } + return this.canvasContext; + } + }, + CLASS_NAME: "OpenLayers.Tile.Image" }); diff --git a/tests/Tile/Image.html b/tests/Tile/Image.html index 0b42064265..f202f6dfe1 100644 --- a/tests/Tile/Image.html +++ b/tests/Tile/Image.html @@ -399,6 +399,31 @@ map.destroy(); }); } + + function test_getCanvasContext(t) { + if (!OpenLayers.CANVAS_SUPPORTED) { + t.plan(0); + } else { + t.plan(1); + + var map = new OpenLayers.Map('map'); + var layer = new OpenLayers.Layer.WMS("OpenLayers WMS", + "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'}); + map.addLayer(layer); + map.setCenter(new OpenLayers.LonLat(0, 0), 5); + + t.delay_call(5, function() { + var tile = layer.grid[0][0]; + if (tile.isLoading) { + t.ok(false, "test_getCanvasContext timeout"); + } else { + t.ok(tile.getCanvasContext() instanceof CanvasRenderingContext2D, + "getCanvasContext() returns CanvasRenderingContext2D instance"); + } + map.destroy(); + }); + } + } From e9097ce066b920269645b01e04708ad6092da813 Mon Sep 17 00:00:00 2001 From: fredj Date: Thu, 19 Jan 2012 16:12:52 +0100 Subject: [PATCH 23/91] More APIdoc for OpenLayers.Tile.Image.getCanvasContext --- lib/OpenLayers/Tile/Image.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/OpenLayers/Tile/Image.js b/lib/OpenLayers/Tile/Image.js index 7baf8bf98e..690e494ed4 100644 --- a/lib/OpenLayers/Tile/Image.js +++ b/lib/OpenLayers/Tile/Image.js @@ -425,6 +425,15 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { * Returns undefined if the browser does not support canvas, if * the tile has no image or if it's currently loading. * + * The function returns a canvas context instance but the + * underlying canvas is still available in the 'canvas' property: + * (code) + * var context = tile.getCanvasContext(); + * if (context) { + * var data = context.canvas.toDataURL('image/jpeg'); + * } + * (end) + * * Returns: * {Boolean} */ From b34f272fa702ee4028fbd6e102973609e4a0bea7 Mon Sep 17 00:00:00 2001 From: fredj Date: Fri, 20 Jan 2012 12:00:20 +0100 Subject: [PATCH 24/91] Optimize the string test --- lib/OpenLayers/Tile/Image.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/OpenLayers/Tile/Image.js b/lib/OpenLayers/Tile/Image.js index 690e494ed4..d9ee4e76e9 100644 --- a/lib/OpenLayers/Tile/Image.js +++ b/lib/OpenLayers/Tile/Image.js @@ -324,7 +324,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { img.style.opacity = 0; if (url) { // don't set crossOrigin if the url is a data URL - img.crossOrigin = url.indexOf('data:') === 0 ? null : ''; + img.crossOrigin = url.substr(0, 5) === 'data:' ? null : ''; img.src = url; } }, From b1cc0c1b9dd6df83569b6d2b6a26386cf76b185c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Thu, 9 Feb 2012 16:58:36 +0100 Subject: [PATCH 25/91] make OpenLayers.js auto-load Spherical.js --- lib/OpenLayers.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index 3ffa1b6a84..78b35da424 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -348,7 +348,8 @@ "OpenLayers/Symbolizer/Text.js", "OpenLayers/Symbolizer/Raster.js", "OpenLayers/Lang.js", - "OpenLayers/Lang/en.js" + "OpenLayers/Lang/en.js", + "OpenLayers/Spherical.js" ]; // etc. } From 4cc1bf18993486d0bde9a6849994b639c064bd20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Thu, 9 Feb 2012 16:59:02 +0100 Subject: [PATCH 26/91] better docs for the Spherical namespace --- lib/OpenLayers/Spherical.js | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/lib/OpenLayers/Spherical.js b/lib/OpenLayers/Spherical.js index ed64c844f8..b19edc8939 100644 --- a/lib/OpenLayers/Spherical.js +++ b/lib/OpenLayers/Spherical.js @@ -3,29 +3,32 @@ * See http://svn.openlayers.org/trunk/openlayers/license.txt for the * full text of the license. */ -/** - * @see http://www.movable-type.co.uk/scripts/latlong.html - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#spherical - */ - - /** * Namespace: Spherical + * The OpenLayers.Spherical namespace includes utility functions for + * calculations on the basis of a spherical earth (ignoring ellipsoidal + * effects), which is accurate enough for most purposes. + * + * Relevant links: + * * http://www.movable-type.co.uk/scripts/latlong.html + * * http://code.google.com/apis/maps/documentation/javascript/reference.html#spherical */ + OpenLayers.Spherical = OpenLayers.Spherical || {}; - OpenLayers.Spherical.DEFAULT_RADIUS = 6378137; - /** * APIFunction: computeDistanceBetween * Computes the distance between two LonLats. * * Parameters: - * from - {} - * to - {} - * radius - {Float} + * from - {} or {Object} Starting point. A LonLat or + * a JavaScript litteral with lon lat properties. + * to - {} or {Object} Ending point. A LonLat or a + * JavaScript litteral with lon lat properties. + * radius - {Float} The radius. Optional. Defaults to the earth's + * radius, i.e. 6378137 meters. * * Returns: * {Float} The distance in meters. @@ -45,8 +48,10 @@ OpenLayers.Spherical.computeDistanceBetween = function(from, to, radius) { * Computes the heading from one LonLat to another LonLat. * * Parameters: - * from - {} - * to - {} + * from - {} or {Object} Starting point. A LonLat or + * a JavaScript litteral with lon lat properties. + * to - {} or {Object} Ending point. A LonLat or a + * JavaScript litteral with lon lat properties. * * Returns: * {Float} The heading in degrees. From 50629f3e50793233419c25cf4695751621151d98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Thu, 9 Feb 2012 16:59:20 +0100 Subject: [PATCH 27/91] add Spherical to the API doc menu --- doc_config/Menu.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc_config/Menu.txt b/doc_config/Menu.txt index 7d685cb73c..1a941749ae 100644 --- a/doc_config/Menu.txt +++ b/doc_config/Menu.txt @@ -458,6 +458,7 @@ Group: OpenLayers { File: Tween (no auto-title, OpenLayers/Tween.js) File: Util (no auto-title, OpenLayers/Util.js) + File: Spherical (no auto-title, OpenLayers/Spherical.js) File: Deprecated (no auto-title, deprecated.js) } # Group: OpenLayers From 3c3092985808aca0b27ed20246b6aeced68bcd6f Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Fri, 10 Feb 2012 09:42:08 +0100 Subject: [PATCH 28/91] Correct spelling --- lib/OpenLayers/Spherical.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Spherical.js b/lib/OpenLayers/Spherical.js index b19edc8939..2fcaf44756 100644 --- a/lib/OpenLayers/Spherical.js +++ b/lib/OpenLayers/Spherical.js @@ -24,9 +24,9 @@ OpenLayers.Spherical.DEFAULT_RADIUS = 6378137; * * Parameters: * from - {} or {Object} Starting point. A LonLat or - * a JavaScript litteral with lon lat properties. + * a JavaScript literal with lon lat properties. * to - {} or {Object} Ending point. A LonLat or a - * JavaScript litteral with lon lat properties. + * JavaScript literal with lon lat properties. * radius - {Float} The radius. Optional. Defaults to the earth's * radius, i.e. 6378137 meters. * @@ -49,9 +49,9 @@ OpenLayers.Spherical.computeDistanceBetween = function(from, to, radius) { * * Parameters: * from - {} or {Object} Starting point. A LonLat or - * a JavaScript litteral with lon lat properties. + * a JavaScript literal with lon lat properties. * to - {} or {Object} Ending point. A LonLat or a - * JavaScript litteral with lon lat properties. + * JavaScript literal with lon lat properties. * * Returns: * {Float} The heading in degrees. From 8d6c9ef1eee650149e0b764fab140c752cb29d9a Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Fri, 10 Feb 2012 09:42:52 +0100 Subject: [PATCH 29/91] Correct documentation --- lib/OpenLayers/Spherical.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/OpenLayers/Spherical.js b/lib/OpenLayers/Spherical.js index 2fcaf44756..4a8956a5b7 100644 --- a/lib/OpenLayers/Spherical.js +++ b/lib/OpenLayers/Spherical.js @@ -27,8 +27,7 @@ OpenLayers.Spherical.DEFAULT_RADIUS = 6378137; * a JavaScript literal with lon lat properties. * to - {} or {Object} Ending point. A LonLat or a * JavaScript literal with lon lat properties. - * radius - {Float} The radius. Optional. Defaults to the earth's - * radius, i.e. 6378137 meters. + * radius - {Float} The radius. Optional. Defaults to 6378137 meters. * * Returns: * {Float} The distance in meters. From 342d624616efd12e67d42cf52ad24ee00a853d7f Mon Sep 17 00:00:00 2001 From: ahocevar Date: Fri, 10 Feb 2012 12:50:13 +0100 Subject: [PATCH 30/91] New crossOriginKeyword property. Set to 'anonymous' for Layer.OSM and Layer.Bing, and not used by default for other layers. --- lib/OpenLayers/Layer/Bing.js | 3 +++ lib/OpenLayers/Layer/OSM.js | 6 ++++++ lib/OpenLayers/Tile/Image.js | 16 ++++++++++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Layer/Bing.js b/lib/OpenLayers/Layer/Bing.js index a33202a724..703c2b5e43 100644 --- a/lib/OpenLayers/Layer/Bing.js +++ b/lib/OpenLayers/Layer/Bing.js @@ -107,6 +107,9 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, { var newArgs = [name, null, options]; OpenLayers.Layer.XYZ.prototype.initialize.apply(this, newArgs); + this.tileOptions = OpenLayers.Util.extend({ + crossOriginKeyword: 'anonymous' + }, this.options.tileOptions); this.loadMetadata(); }, diff --git a/lib/OpenLayers/Layer/OSM.js b/lib/OpenLayers/Layer/OSM.js index 320c4540ef..69f411756b 100644 --- a/lib/OpenLayers/Layer/OSM.js +++ b/lib/OpenLayers/Layer/OSM.js @@ -73,6 +73,12 @@ OpenLayers.Layer.OSM = OpenLayers.Class(OpenLayers.Layer.XYZ, { * layer option can be set in this object (e.g. * ). */ + initialize: function(name, url, options) { + OpenLayers.Layer.XYZ.prototype.initialize.apply(this, arguments); + this.tileOptions = OpenLayers.Util.extend({ + crossOriginKeyword: 'anonymous' + }, this.options && this.options.tileOptions); + }, /** * Method: clone diff --git a/lib/OpenLayers/Tile/Image.js b/lib/OpenLayers/Tile/Image.js index d9ee4e76e9..309976a22f 100644 --- a/lib/OpenLayers/Tile/Image.js +++ b/lib/OpenLayers/Tile/Image.js @@ -87,6 +87,16 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { * the tile image. */ canvasContext: null, + + /** + * APIProperty: crossOriginKeyword + * The value of the crossorigin keyword to use when loading images. This is + * only relevant when using for tiles from remote + * origins and should be set to either 'anonymous' or 'use-credentials' + * for servers that send Access-Control-Allow-Origin headers with their + * tiles. + */ + crossOriginKeyword: null, /** TBD 3.0 - reorder the parameters to the init function to remove * URL. the getUrl() function on the layer gets called on @@ -305,7 +315,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { } else { OpenLayers.Event.observe(img, "load", load); OpenLayers.Event.observe(img, "error", load); - img.crossOrigin = null; + delete img.crossOrigin; img.src = this.blankImageUrl; } } @@ -324,7 +334,9 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { img.style.opacity = 0; if (url) { // don't set crossOrigin if the url is a data URL - img.crossOrigin = url.substr(0, 5) === 'data:' ? null : ''; + if (this.crossOriginKeyword && url.substr(0, 5 !== 'data:')) { + img.crossOrigin = this.crossOriginKeyword; + } img.src = url; } }, From cebc7e60de1a13cde910c7648d707c926c38d6fe Mon Sep 17 00:00:00 2001 From: ahocevar Date: Fri, 10 Feb 2012 13:03:18 +0100 Subject: [PATCH 31/91] Don't displayOutsideMaxExtent when wrapDateLine is set. p=scaddenp, r=me (closes http://trac.osgeo.org/openlayers/ticket/3616) --- lib/OpenLayers/Layer.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js index 54c97f0d13..f7614db4bc 100644 --- a/lib/OpenLayers/Layer.js +++ b/lib/OpenLayers/Layer.js @@ -361,10 +361,6 @@ OpenLayers.Layer = OpenLayers.Class({ } } - - if (this.wrapDateLine) { - this.displayOutsideMaxExtent = true; - } }, /** From f8099e9ab10e60209f4bb739f25c204c10374947 Mon Sep 17 00:00:00 2001 From: fredj Date: Fri, 10 Feb 2012 13:46:13 +0100 Subject: [PATCH 32/91] Unset crossOrigin when setting blankImageUrl to the image. Tested with FF 10, Chrome 16 and 18. --- lib/OpenLayers/Tile/Image.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Tile/Image.js b/lib/OpenLayers/Tile/Image.js index 309976a22f..dfbf1bda43 100644 --- a/lib/OpenLayers/Tile/Image.js +++ b/lib/OpenLayers/Tile/Image.js @@ -315,7 +315,9 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { } else { OpenLayers.Event.observe(img, "load", load); OpenLayers.Event.observe(img, "error", load); - delete img.crossOrigin; + if (img.crossOrigin) { + img.crossOrigin = null; + } img.src = this.blankImageUrl; } } From 334f83ff850da0bf47aa6b66c7e1ee8ce9d43801 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Fri, 10 Feb 2012 14:15:26 +0100 Subject: [PATCH 33/91] Updated tests for cebc7e60de1a13cde910c7648d707c926c38d6fe. See http://trac.osgeo.org/openlayers/ticket/3616. --- tests/Layer/WrapDateLine.html | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tests/Layer/WrapDateLine.html b/tests/Layer/WrapDateLine.html index 15e9d5771a..ca993b9011 100644 --- a/tests/Layer/WrapDateLine.html +++ b/tests/Layer/WrapDateLine.html @@ -127,7 +127,7 @@ } function test_Layer_WrapDateLine_WMS (t) { - t.plan( 3 ); + t.plan( 4 ); var url = "http://octo.metacarta.com/cgi-bin/mapserv"; layer = new OpenLayers.Layer.WMS(name, url, params, {'wrapDateLine':true,encodeBBOX:true, buffer: 2}); @@ -135,13 +135,14 @@ 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."); - t.eq(layer.grid[0][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%2C450%2C180%2C630&WIDTH=256&HEIGHT=256", "cell [0][0] is wrapped around the world lon, but not lat"); - t.eq(layer.grid[0][3].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=-180%2C450%2C0%2C630&WIDTH=256&HEIGHT=256", "cell [3][0] is not wrapped at all."); + t.eq(layer.grid[3][1].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=-180%2C-90%2C0%2C90&WIDTH=256&HEIGHT=256", "cell [3][1] is wrapped around the world."); + t.eq(layer.grid[3][2].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][2] is not wrapped at all."); + t.ok(layer.grid[0][2].url == null, "no latitudinal wrapping - tile not loaded if outside maxExtent"); m.destroy(); } function test_Layer_WrapDateLine_KaMap (t) { - t.plan( 3 ); + t.plan( 4 ); var layer = new OpenLayers.Layer.KaMap( "Blue Marble NG", "http://www.openlayers.org/world/index.php", @@ -150,13 +151,14 @@ var m = new OpenLayers.Map('map', {adjustZoom: function(z) {return z;}}); m.addLayer(layer); m.zoomToMaxExtent(); - t.eq(layer.grid[0][0].url, "http://www.openlayers.org/world/index.php?g=satellite&map=world&i=jpeg&t=-1280&l=0&s=221471921.25", "grid[0][0] kamap is okay"); - t.eq(layer.grid[0][3].url, "http://www.openlayers.org/world/index.php?g=satellite&map=world&i=jpeg&t=-1280&l=-256&s=221471921.25", "grid[0][3] kamap is okay"); - t.eq(layer.grid[3][0].url, "http://www.openlayers.org/world/index.php?g=satellite&map=world&i=jpeg&t=-512&l=0&s=221471921.25", "grid[3][0] is okay"); + t.eq(layer.grid[5][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"); + t.eq(layer.grid[5][6].url, "http://www.openlayers.org/world/index.php?g=satellite&map=world&i=jpeg&t=0&l=0&s=221471921.25", "grid[5][6] kamap is okay"); + t.eq(layer.grid[5][5].url, "http://www.openlayers.org/world/index.php?g=satellite&map=world&i=jpeg&t=0&l=-256&s=221471921.25", "grid[5][5] is okay"); + t.ok(layer.grid[7][6].url == null, "no latitudinal wrapping - tile not loaded if outside maxExtent"); m.destroy(); } function test_Layer_WrapDateLine_WMS_Overlay (t) { - t.plan( 3 ); + t.plan( 4 ); var url = "http://octo.metacarta.com/cgi-bin/mapserv"; baselayer = new OpenLayers.Layer.WMS(name, url, params, {'wrapDateLine':true, buffer: 2}); var layer = new OpenLayers.Layer.WMS( "DM Solutions Demo", @@ -168,9 +170,10 @@ var m = new OpenLayers.Map('map', {adjustZoom: function(z) {return z;}}); m.addLayers([baselayer,layer]); m.zoomToMaxExtent(); - t.eq(layer.grid[0][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%2C450%2C180%2C630&WIDTH=256&HEIGHT=256", "grid[0][0] wms overlay is okay"); - t.eq(layer.grid[0][3].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=-180%2C450%2C0%2C630&WIDTH=256&HEIGHT=256", "grid[0][3] wms overlay is okay"); - 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[3][0] wms overlay okay"); + 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"); + t.eq(layer.grid[3][1].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=-180%2C-90%2C0%2C90&WIDTH=256&HEIGHT=256", "grid[0][3] wms overlay is okay"); + t.eq(layer.grid[3][2].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[3][0] wms overlay okay"); + t.ok(layer.grid[0][2].url == null, "no latitudinal wrapping - tile not loaded if outside maxExtent"); m.destroy(); } From b17c7b69f25ce0ddbaf720f91b7d48328b005831 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Fri, 10 Feb 2012 15:46:45 +0100 Subject: [PATCH 34/91] Adding comment about GMaps API version. Closes http://trac.osgeo.org/openlayers/ticket/2984. --- lib/OpenLayers/Layer/Google/v3.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Layer/Google/v3.js b/lib/OpenLayers/Layer/Google/v3.js index bf8618130a..b99d93bffc 100644 --- a/lib/OpenLayers/Layer/Google/v3.js +++ b/lib/OpenLayers/Layer/Google/v3.js @@ -11,10 +11,15 @@ /** * Constant: OpenLayers.Layer.Google.v3 * - * Mixin providing functionality specific to the Google Maps API v3. 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. + * Mixin providing functionality specific to the Google Maps API v3 <= v3.6. + * 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. To use this layer, + * you must include the GMaps API (<= v3.6) in your html: + * + * (code) + * + * (end) */ OpenLayers.Layer.Google.v3 = { From 68a6c62f0b9880b98e54e09cf0daa99d6c42f2d5 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Fri, 10 Feb 2012 18:03:22 +0100 Subject: [PATCH 35/91] Documenting tileOptions defaults. --- lib/OpenLayers/Layer/Bing.js | 10 ++++++++++ lib/OpenLayers/Layer/OSM.js | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/lib/OpenLayers/Layer/Bing.js b/lib/OpenLayers/Layer/Bing.js index 703c2b5e43..f593551ef7 100644 --- a/lib/OpenLayers/Layer/Bing.js +++ b/lib/OpenLayers/Layer/Bing.js @@ -74,6 +74,16 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, { */ metadataParams: null, + /** APIProperty: tileOptions + * {Object} optional configuration options for instances + * created by this Layer. Default is + * + * (code) + * {crossOriginKeyword: 'anonymous'} + * (end) + */ + tileOptions: null, + /** * Constructor: OpenLayers.Layer.Bing * Create a new Bing layer. diff --git a/lib/OpenLayers/Layer/OSM.js b/lib/OpenLayers/Layer/OSM.js index 69f411756b..04e7b04454 100644 --- a/lib/OpenLayers/Layer/OSM.js +++ b/lib/OpenLayers/Layer/OSM.js @@ -63,6 +63,25 @@ OpenLayers.Layer.OSM = OpenLayers.Class(OpenLayers.Layer.XYZ, { */ wrapDateLine: true, + /** APIProperty: tileOptions + * {Object} optional configuration options for instances + * created by this Layer. Default is + * + * (code) + * {crossOriginKeyword: 'anonymous'} + * (end) + * + * When using OSM tilesets other than the default ones, it may be + * necessary to set this to + * + * (code) + * {crossOriginKeyword: null} + * (end) + * + * if the server does not send Access-Control-Allow-Origin headers. + */ + tileOptions: null, + /** * Constructor: OpenLayers.Layer.OSM * From c6312b613ba3e4ce6fe18d1fa9c516eb55e812fc Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Fri, 10 Feb 2012 23:55:51 +0100 Subject: [PATCH 36/91] correct a typo in release notes CSS example --- notes/2.12.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notes/2.12.md b/notes/2.12.md index 2182009676..d312132ec6 100644 --- a/notes/2.12.md +++ b/notes/2.12.md @@ -62,7 +62,7 @@ We are deprecating the Rico classes/objects in OpenLayers. This has the followin The `roundedCorner` option of `Control.LayerSwitcher` is deprecated, and it now defaults to `false`. Setting it to true results in deprecation messages being output on the console. If you still want to set `roundedCorner` to `true` (you should not!) you need to make sure that the Rico/Corner.js and Rico/Color.js scripts are loaded in the page. This can be ensured by adding Rico/Corner.js in the build profile. The controls.html example demonstrates how to use `border-radius` to round corners of a layer switcher: - olControlLayerSwitcher .layersDiv { + .olControlLayerSwitcher .layersDiv { border-radius: 10px 0 0 10px; } From ca2c3526b3f593646b74db442a6b4af7e618e6db Mon Sep 17 00:00:00 2001 From: ahocevar Date: Sat, 11 Feb 2012 11:16:21 +0100 Subject: [PATCH 37/91] Adding notes about the crossOriginKeyword tile option for Layer.OSM and Layer.Bing. --- notes/2.12.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/notes/2.12.md b/notes/2.12.md index d312132ec6..3aa2db8eda 100644 --- a/notes/2.12.md +++ b/notes/2.12.md @@ -76,10 +76,14 @@ The base `OpenLayers.Geometry` class no longer depends on `OpenLayers.Format.WKT Without the WKT format included (by default), the `OpenLayers.Geometry::toString` method now returns "[object Object]." Previously, it returned the Well-Known Text representation of the geometry. To maintain the previous behavior, include the OpenLayers/Format/WKT.js file in your build. -## OSM Layer +## 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. (See https://github.com/openlayers/openlayers/issues/138) +The `OpenLayers.Tile.Image` class now has a method to get a canvas context for processing tiles. Since both OSM and Bing set Access-Control-Allow-Origin headers for their tiles, it is possible to manipulate a canvas that these tiles were rendered to even if the tiles come from a remote origin. Especially when working with custom OSM tilesets from servers that do not send Access-Control-Allow-Origin headers, it is now necessary to configure the layer with + + tileOptions: {crossOriginKeyword: null} + ## Projection & SphericalMercator In previous releases, coordinate transforms between EPSG:4326 and EPSG:900913 were defined in the SphericalMercator.js script. In 2.12, these default transforms are included in the Projection.js script. The Projection.js script is included as a dependency in builds with any layer types, so no special build configuration is necessary to get the web mercator transforms. From 6385be7ffe56abd3b9722e4c1407ddac3174b941 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Sat, 11 Feb 2012 12:34:40 +0100 Subject: [PATCH 38/91] Template for the Attribution control. This allows to add map specific copyright, or copyright required for tools like geocoders that are used in the context of the map. --- lib/OpenLayers/Control/Attribution.js | 12 +++++++++++- tests/Control/Attribution.html | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Control/Attribution.js b/lib/OpenLayers/Control/Attribution.js index 621f6be77d..25aa069280 100644 --- a/lib/OpenLayers/Control/Attribution.js +++ b/lib/OpenLayers/Control/Attribution.js @@ -24,6 +24,14 @@ OpenLayers.Control.Attribution = */ separator: ", ", + /** + * APIProperty: template + * {String} Template for the attribution. This has to include the substring + * "${layers}", which will be replaced by the layer specific + * attributions, separated by . The default is "${layers}". + */ + template: "${layers}", + /** * Constructor: OpenLayers.Control.Attribution * @@ -86,7 +94,9 @@ OpenLayers.Control.Attribution = } } } - this.div.innerHTML = attributions.join(this.separator); + this.div.innerHTML = OpenLayers.String.format(this.template, { + layers: attributions.join(this.separator) + }); } }, diff --git a/tests/Control/Attribution.html b/tests/Control/Attribution.html index c1c1ef228b..04b85cfdb3 100644 --- a/tests/Control/Attribution.html +++ b/tests/Control/Attribution.html @@ -30,8 +30,9 @@ map.addLayer(new OpenLayers.Layer("name", {'attribution':'My layer 2!'})); t.eq(control.div.innerHTML, 'My layer!, My layer 2!', "Attribution correct with two layers."); control.separator = '|'; + control.template = "Map Copyright (c) 2012 by Foo Bar; ${layers}"; map.addLayer(new OpenLayers.Layer("name",{'attribution':'My layer 3!'})); - t.eq(control.div.innerHTML, 'My layer!|My layer 2!|My layer 3!', "Attribution correct with three layers and diff seperator."); + t.eq(control.div.innerHTML, 'Map Copyright (c) 2012 by Foo Bar; My layer!|My layer 2!|My layer 3!', "Attribution correct with three layers and diff seperator."); } From 718679a025b7cb0f1022d4ca9f29d35ea6ce9b01 Mon Sep 17 00:00:00 2001 From: oleg-poligon Date: Sun, 12 Feb 2012 02:04:03 +0400 Subject: [PATCH 39/91] set GMaps API version to 3.6 in allOverlays Layer Example --- examples/google-v3-alloverlays.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/google-v3-alloverlays.html b/examples/google-v3-alloverlays.html index 10dcde4364..dac1d15f13 100644 --- a/examples/google-v3-alloverlays.html +++ b/examples/google-v3-alloverlays.html @@ -8,7 +8,7 @@ - + From 134f24480a9e6ebf0c71891e52a6b1d456ad1996 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Sun, 12 Feb 2012 21:56:41 +0100 Subject: [PATCH 40/91] Move the popup close box sizing to CSS --- lib/OpenLayers/Popup.js | 6 ++---- notes/2.12.md | 3 +++ theme/default/style.css | 2 ++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Popup.js b/lib/OpenLayers/Popup.js index 36f666e73f..f6f6e65871 100644 --- a/lib/OpenLayers/Popup.js +++ b/lib/OpenLayers/Popup.js @@ -872,13 +872,11 @@ OpenLayers.Popup = OpenLayers.Class({ */ addCloseBox: function(callback) { - this.closeDiv = OpenLayers.Util.createDiv( - this.id + "_close", null, {w: 17, h: 17} - ); + this.closeDiv = OpenLayers.Util.createDiv(this.id + "_close"); this.closeDiv.className = "olPopupCloseBox"; // use the content div's css padding to determine if we should - // padd the close div + // pad the close div var contentDivPadding = this.getContentDivPadding(); this.closeDiv.style.right = contentDivPadding.right + "px"; diff --git a/notes/2.12.md b/notes/2.12.md index 3aa2db8eda..52a122b765 100644 --- a/notes/2.12.md +++ b/notes/2.12.md @@ -145,3 +145,6 @@ In addition, OpenLayers no longer modifies any native prototypes or objects by d * Function.prototype.bindAsEventListener * Event.stop +## Popup close box size + +The size of the close box is now configurable in CSS instead of the fixed 17x17px (`.olPopupCloseBox`) diff --git a/theme/default/style.css b/theme/default/style.css index c695689ff7..703eb961c2 100644 --- a/theme/default/style.css +++ b/theme/default/style.css @@ -259,6 +259,8 @@ div.olControlSaveFeaturesItemInactive { .olPopupCloseBox { background: url("img/close.gif") no-repeat; + width: 17px; + height: 17px; cursor: pointer; } From 1f539470bbba6b617139205ad7ae27faefe427d2 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Mon, 13 Feb 2012 09:42:09 +0100 Subject: [PATCH 41/91] add box drawing to draw-feature control example so it is easier to find for people --- examples/draw-feature.html | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/examples/draw-feature.html b/examples/draw-feature.html index d292794f63..f70e9eabf3 100644 --- a/examples/draw-feature.html +++ b/examples/draw-feature.html @@ -33,18 +33,27 @@ var pointLayer = new OpenLayers.Layer.Vector("Point Layer"); var lineLayer = new OpenLayers.Layer.Vector("Line Layer"); var polygonLayer = new OpenLayers.Layer.Vector("Polygon Layer"); + var boxLayer = new OpenLayers.Layer.Vector("Box layer"); - map.addLayers([wmsLayer, pointLayer, lineLayer, polygonLayer]); + map.addLayers([wmsLayer, pointLayer, lineLayer, polygonLayer, boxLayer]); map.addControl(new OpenLayers.Control.LayerSwitcher()); map.addControl(new OpenLayers.Control.MousePosition()); drawControls = { point: new OpenLayers.Control.DrawFeature(pointLayer, - OpenLayers.Handler.Point), + OpenLayers.Handler.Point), line: new OpenLayers.Control.DrawFeature(lineLayer, - OpenLayers.Handler.Path), + OpenLayers.Handler.Path), polygon: new OpenLayers.Control.DrawFeature(polygonLayer, - OpenLayers.Handler.Polygon) + OpenLayers.Handler.Polygon), + box: new OpenLayers.Control.DrawFeature(boxLayer, + OpenLayers.Handler.RegularPolygon, { + handlerOptions: { + sides: 4, + irregular: true + } + } + ) }; for(var key in drawControls) { @@ -80,11 +89,11 @@

    OpenLayers Draw Feature Example

    - point, line, linestring, polygon, digitizing, geometry, draw, drag + point, line, linestring, polygon, box, digitizing, geometry, draw, drag

    - Demonstrate on-screen digitizing tools for point, line, and polygon creation. + Demonstrate on-screen digitizing tools for point, line, polygon and box creation.

    @@ -107,6 +116,10 @@
  • +
  • + + +
  • @@ -119,6 +132,8 @@ Double-click to finish drawing.

    With the polygon drawing control active, click on the map to add the points that make up your polygon. Double-click to finish drawing.

    +

    With the box drawing control active, click in the map and drag the mouse to get a rectangle. Release + the mouse to finish.

    With any drawing control active, paning the map can still be achieved. Drag the map as usual for that.

    Hold down the shift key while drawing to activate freehand mode. While drawing lines or polygons From 2dabac734ce3e12c5b923695b3fd30377d488a92 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 13 Feb 2012 19:59:59 +0100 Subject: [PATCH 42/91] Revert "Move the popup close box sizing to CSS" Moving the box size to CSS broke `Popup.setSize()`; the function expects a width for the padding computation. Because this function is called before the div is added to the DOM, the size can't be computed. This reverts commit 134f24480a9e6ebf0c71891e52a6b1d456ad1996. --- lib/OpenLayers/Popup.js | 6 ++++-- notes/2.12.md | 3 --- theme/default/style.css | 2 -- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/OpenLayers/Popup.js b/lib/OpenLayers/Popup.js index f6f6e65871..36f666e73f 100644 --- a/lib/OpenLayers/Popup.js +++ b/lib/OpenLayers/Popup.js @@ -872,11 +872,13 @@ OpenLayers.Popup = OpenLayers.Class({ */ addCloseBox: function(callback) { - this.closeDiv = OpenLayers.Util.createDiv(this.id + "_close"); + this.closeDiv = OpenLayers.Util.createDiv( + this.id + "_close", null, {w: 17, h: 17} + ); this.closeDiv.className = "olPopupCloseBox"; // use the content div's css padding to determine if we should - // pad the close div + // padd the close div var contentDivPadding = this.getContentDivPadding(); this.closeDiv.style.right = contentDivPadding.right + "px"; diff --git a/notes/2.12.md b/notes/2.12.md index 52a122b765..3aa2db8eda 100644 --- a/notes/2.12.md +++ b/notes/2.12.md @@ -145,6 +145,3 @@ In addition, OpenLayers no longer modifies any native prototypes or objects by d * Function.prototype.bindAsEventListener * Event.stop -## Popup close box size - -The size of the close box is now configurable in CSS instead of the fixed 17x17px (`.olPopupCloseBox`) diff --git a/theme/default/style.css b/theme/default/style.css index 703eb961c2..c695689ff7 100644 --- a/theme/default/style.css +++ b/theme/default/style.css @@ -259,8 +259,6 @@ div.olControlSaveFeaturesItemInactive { .olPopupCloseBox { background: url("img/close.gif") no-repeat; - width: 17px; - height: 17px; cursor: pointer; } From ce71a5a3fd5ec78f8a4ea5c68cf6e7eeb4876224 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Tue, 14 Feb 2012 00:07:57 +0100 Subject: [PATCH 43/91] Google Static Maps API. Simple and limited to 1000 views. --- examples/google-static.html | 33 +++++++++++++++++++++++++ examples/google-static.js | 48 +++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 examples/google-static.html create mode 100644 examples/google-static.js diff --git a/examples/google-static.html b/examples/google-static.html new file mode 100644 index 0000000000..e7e7885397 --- /dev/null +++ b/examples/google-static.html @@ -0,0 +1,33 @@ + + + + + + + OpenLayers Google (Static Maps API) Grid Layer Example + + + + +

    Google (Static Maps API) Grid Layer Example

    +
    + Google, grid, static, GMaps +
    +

    + Using the Google Static Maps API with a Grid Layer. +

    +
    +
    +

    + A Grid layer with a custom getURL method can be + used to request static maps for a specific extent and zoom + level. The Google Static Maps API is the most reliable way to + get Google base maps in OpenLayers. Note, however, that this is + limited to 1000 page views per viewer. Every map center or zoom + level change increases the page view counter by 1. +

    +
    + + + + diff --git a/examples/google-static.js b/examples/google-static.js new file mode 100644 index 0000000000..dde0903ea8 --- /dev/null +++ b/examples/google-static.js @@ -0,0 +1,48 @@ +var options = { + singleTile: true, + ratio: 1, + isBaseLayer: true, + wrapDateLine: true, + getURL: function() { + var center = this.map.getCenter().transform("EPSG:3857", "EPSG:4326"), + size = this.map.getSize(); + return [ + this.url, "¢er=", center.lat, ",", center.lon, + "&zoom=", this.map.getZoom(), "&size=", size.w, "x", size.h + ].join(""); + } +}; + +var map = new OpenLayers.Map({ + div: "map", + maxExtent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34], + maxResolution: 156543.03390625, + units: "m", + projection: "EPSG:3857", + numZoomLevels: 22, + layers: [ + new OpenLayers.Layer.Grid( + "Google Physical", + "http://maps.googleapis.com/maps/api/staticmap?sensor=false&maptype=terrain", + null, options + ), + new OpenLayers.Layer.Grid( + "Google Streets", + "http://maps.googleapis.com/maps/api/staticmap?sensor=false&maptype=roadmap", + null, options + ), + new OpenLayers.Layer.Grid( + "Google Hybrid", + "http://maps.googleapis.com/maps/api/staticmap?sensor=false&maptype=hybrid", + null, options + ), + new OpenLayers.Layer.Grid( + "Google Satellite", + "http://maps.googleapis.com/maps/api/staticmap?sensor=false&maptype=satellite", + null, options + ) + ], + center: new OpenLayers.LonLat(10.2, 48.9).transform("EPSG:4326", "EPSG:3857"), + zoom: 5 +}); +map.addControl(new OpenLayers.Control.LayerSwitcher()); From fe0bc333ca8bfe22a099e7a237df72a23d6b1dfc Mon Sep 17 00:00:00 2001 From: ahocevar Date: Tue, 14 Feb 2012 00:14:15 +0100 Subject: [PATCH 44/91] Improving example documentation. --- examples/google-static.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/google-static.html b/examples/google-static.html index e7e7885397..ab7d788dd8 100644 --- a/examples/google-static.html +++ b/examples/google-static.html @@ -18,14 +18,16 @@

    -

    - A Grid layer with a custom getURL method can be +

    A Grid layer with a custom getURL method can be used to request static maps for a specific extent and zoom level. The Google Static Maps API is the most reliable way to get Google base maps in OpenLayers. Note, however, that this is - limited to 1000 page views per viewer. Every map center or zoom - level change increases the page view counter by 1. + limited to 1000 page views per viewer per day. Every map center + or zoom level change increases the page view counter by 1.

    +

    Look at the + google-static.js + source to see how this is done.

    From d387add3e2b2adace3e82ef5c6380cdecb1bafa1 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Tue, 14 Feb 2012 12:28:29 +0100 Subject: [PATCH 45/91] Note about size limitations. --- examples/google-static.html | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/google-static.html b/examples/google-static.html index ab7d788dd8..96847cb83b 100644 --- a/examples/google-static.html +++ b/examples/google-static.html @@ -21,13 +21,17 @@

    A Grid layer with a custom getURL method can be used to request static maps for a specific extent and zoom level. The Google Static Maps API is the most reliable way to - get Google base maps in OpenLayers. Note, however, that this is - limited to 1000 page views per viewer per day. Every map center + get Google base maps in OpenLayers. Note, however, that the + free version of this is limited to a map size of 640x640 pixels + (1280x1280 if the scale=2 url parameter is used) + and 1000 page views per viewer per day. Every map center or zoom level change increases the page view counter by 1.

    Look at the google-static.js - source to see how this is done. + source to see how this is done. See the + Static Maps API V2 Developer Guide + for details on the API. From 692fe2dd1286f2f6bebfa1fca30e7d6e1de75353 Mon Sep 17 00:00:00 2001 From: fredj Date: Tue, 14 Feb 2012 14:32:15 +0100 Subject: [PATCH 46/91] Bounds.fromSize: size can be a simple object, update doc. --- lib/OpenLayers/BaseTypes/Bounds.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/BaseTypes/Bounds.js b/lib/OpenLayers/BaseTypes/Bounds.js index 5a527ca02a..5dd6d2c906 100644 --- a/lib/OpenLayers/BaseTypes/Bounds.js +++ b/lib/OpenLayers/BaseTypes/Bounds.js @@ -716,7 +716,8 @@ OpenLayers.Bounds.fromArray = function(bbox, reverseAxisOrder) { * from a size * * Parameters: - * size - {} + * size - {|Object} OpenLayers.Size or an object with + * a 'w' and 'h' properties. * * Returns: * {} New bounds object built from the passed-in size. From add094b28438d4364fcd9f4c461a5421248b6892 Mon Sep 17 00:00:00 2001 From: fredj Date: Tue, 14 Feb 2012 14:46:47 +0100 Subject: [PATCH 47/91] tileSize property already defined in parent class (Layer.Grid) --- lib/OpenLayers/Layer/ArcIMS.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/OpenLayers/Layer/ArcIMS.js b/lib/OpenLayers/Layer/ArcIMS.js index eb7dbc983c..bfe01811fa 100644 --- a/lib/OpenLayers/Layer/ArcIMS.js +++ b/lib/OpenLayers/Layer/ArcIMS.js @@ -29,12 +29,6 @@ OpenLayers.Layer.ArcIMS = OpenLayers.Class(OpenLayers.Layer.Grid, { ServiceName: '' }, - /** - * APIProperty: tileSize - * {} Size for tiles. Default is 512x512. - */ - tileSize: null, - /** * APIProperty: featureCoordSys * {String} Code for feature coordinate system. Default is "4326". From cd8fa55b0ede4488a622b243c9f7793facfcd6eb Mon Sep 17 00:00:00 2001 From: Xavier Mamano Date: Tue, 14 Feb 2012 16:44:36 +0100 Subject: [PATCH 48/91] Build: ignore trailing space in @requires dependencies --- tools/mergejs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/mergejs.py b/tools/mergejs.py index 5a8ec42b4e..a0b7566af0 100755 --- a/tools/mergejs.py +++ b/tools/mergejs.py @@ -43,7 +43,7 @@ import sys SUFFIX_JAVASCRIPT = ".js" -RE_REQUIRE = "@requires?:? (.*)\n" # TODO: Ensure in comment? +RE_REQUIRE = "@requires?:?\s+(\S*)\s*\n" # TODO: Ensure in comment? class MissingImport(Exception): """Exception raised when a listed import is not found in the lib.""" From fe8a00d5c9a815e1e3acdb8035ba0acb7ff9ce15 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Tue, 14 Feb 2012 17:23:01 +0100 Subject: [PATCH 49/91] Support the culture attribute in the Bing Layer. p=dcabasson, r=me (closes http://trac.osgeo.org/openlayers/ticket/3598) --- lib/OpenLayers/Layer/Bing.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/OpenLayers/Layer/Bing.js b/lib/OpenLayers/Layer/Bing.js index f593551ef7..68ea9efd3a 100644 --- a/lib/OpenLayers/Layer/Bing.js +++ b/lib/OpenLayers/Layer/Bing.js @@ -67,6 +67,13 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, { */ type: "Road", + /** + * APIProperty: culture + * {String} The culture identifier. See http://msdn.microsoft.com/en-us/library/ff701709.aspx + * for the definition and the possible values. Default is "en-US". + */ + culture: "en-US", + /** * APIProperty: metadataParams * {Object} Optional url parameters for the Get Imagery Metadata request @@ -155,6 +162,7 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, { initLayer: function() { var res = this.metadata.resourceSets[0].resources[0]; var url = res.imageUrl.replace("{quadkey}", "${quadkey}"); + url = url.replace("{culture}", this.culture); this.url = []; for (var i=0; i Date: Tue, 14 Feb 2012 18:56:46 +0100 Subject: [PATCH 50/91] A configuration file based on a directive `[exclude]` is a anti-pattern, so is proposed to remove `library.cfg`. --- build/library.cfg | 45 --------------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 build/library.cfg diff --git a/build/library.cfg b/build/library.cfg deleted file mode 100644 index f4d66faffe..0000000000 --- a/build/library.cfg +++ /dev/null @@ -1,45 +0,0 @@ -# This file includes the OpenLayers code to create a build for everything that -# does not require vector support. - -[first] - -[last] - -[include] - -[exclude] -Firebug -OpenLayers.js -OpenLayers/Format/GeoRSS.js -OpenLayers/Format/GML.js -OpenLayers/Format/WKT.js -OpenLayers/Format/KML.js -OpenLayers/Format/WFS.js -OpenLayers/Format.js -OpenLayers/Handler/Path.js -OpenLayers/Handler/Point.js -OpenLayers/Handler/Polygon.js -OpenLayers/Handler/Select.js -OpenLayers/Geometry/Collection.js -OpenLayers/Geometry/Curve.js -OpenLayers/Geometry/LinearRing.js -OpenLayers/Geometry/LineString.js -OpenLayers/Geometry/MultiLineString.js -OpenLayers/Geometry/MultiPoint.js -OpenLayers/Geometry/MultiPolygon.js -OpenLayers/Geometry/Point.js -OpenLayers/Geometry/Polygon.js -OpenLayers/Geometry.js -OpenLayers/Layer/Vector.js -OpenLayers/Control/DrawFeature.js -OpenLayers/Control/EditingToolbar.js -OpenLayers/Control/SelectFeature.js -OpenLayers/Feature/Vector.js -OpenLayers/Renderer -OpenLayers/Renderer/Elements.js -OpenLayers/Renderer/SVG.js -OpenLayers/Renderer/VML.js -OpenLayers/Renderer.js -OpenLayers/Lang - - From da3dc76a6d34c7fc1790b67b4f296b00151bb49b Mon Sep 17 00:00:00 2001 From: ahocevar Date: Tue, 14 Feb 2012 20:06:52 +0100 Subject: [PATCH 51/91] Making the delay for removing the backbuffer configurable. This helps users who want to avoid having old and new tiles on the screen for transparent single tile layers. r=@elemoine (closes #216) --- lib/OpenLayers/Layer/Grid.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index 86bf9488a5..a58c7e7ce2 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -173,7 +173,15 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { * flash effects caused by tile animation. */ backBufferTimerId: null, - + + /** + * APIProperty: removeBackBufferDelay + * {Number} Delay for removing the backbuffer when all tiles have finished + * loading. Can be set to 0 when no css opacity transitions for the + * olTileImage class are used. Default is 2500. + */ + removeBackBufferDelay: 2500, + /** * Register a listener for a particular event with the following syntax: * (code) @@ -972,7 +980,7 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { // effects due to the animation of tile displaying this.backBufferTimerId = window.setTimeout( OpenLayers.Function.bind(this.removeBackBuffer, this), - 2500 + this.removeBackBufferDelay ); } } From 52931daf32f0580119aabb5f0c36dcafe62c1a50 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 15 Feb 2012 09:14:31 +0100 Subject: [PATCH 52/91] Fix spelling in test-function. No functional change. --- tests/Control/Measure.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Control/Measure.html b/tests/Control/Measure.html index 045f807d36..4d060ea97d 100644 --- a/tests/Control/Measure.html +++ b/tests/Control/Measure.html @@ -3,7 +3,7 @@ From cfaaa352f8b109bdba05ae7a5adce888ba955f79 Mon Sep 17 00:00:00 2001 From: Pierre GIRAUD Date: Wed, 15 Feb 2012 12:17:39 +0100 Subject: [PATCH 56/91] Update lib/OpenLayers/Format/GPX.js --- lib/OpenLayers/Format/GPX.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/OpenLayers/Format/GPX.js b/lib/OpenLayers/Format/GPX.js index e322e4f0e4..8da76193d2 100644 --- a/lib/OpenLayers/Format/GPX.js +++ b/lib/OpenLayers/Format/GPX.js @@ -73,7 +73,7 @@ OpenLayers.Format.GPX = OpenLayers.Class(OpenLayers.Format.XML, { schemaLocation: "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd", /** - * Property: creator + * APIProperty: creator * {String} The creator attribute to be added to the written GPX files. * Defaults to "OpenLayers" */ From a40ae7ef11a4690085082ec9a2e300b9edd98c8d Mon Sep 17 00:00:00 2001 From: fredj Date: Wed, 15 Feb 2012 12:30:05 +0100 Subject: [PATCH 57/91] If sphericalMercator, use default values from Projection.defaults --- lib/OpenLayers/Layer/XYZ.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/lib/OpenLayers/Layer/XYZ.js b/lib/OpenLayers/Layer/XYZ.js index 7977a3255f..4c2bfc051d 100644 --- a/lib/OpenLayers/Layer/XYZ.js +++ b/lib/OpenLayers/Layer/XYZ.js @@ -70,19 +70,10 @@ OpenLayers.Layer.XYZ = OpenLayers.Class(OpenLayers.Layer.Grid, { * options - {Object} Hashtable of extra options to tag onto the layer */ initialize: function(name, url, options) { - if (options && options.sphericalMercator || this.sphericalMercator) { - options = OpenLayers.Util.extend({ - maxExtent: new OpenLayers.Bounds( - -128 * 156543.03390625, - -128 * 156543.03390625, - 128 * 156543.03390625, - 128 * 156543.03390625 - ), - maxResolution: 156543.03390625, - numZoomLevels: 19, - units: "m", - projection: "EPSG:900913" - }, options); + options = options || {}; + if (options.sphericalMercator || this.sphericalMercator) { + options.projection = new OpenLayers.Projection('EPSG:900913'); + options.numZoomLevels = 19; } url = url || this.url; name = name || this.name; From cd3ffa205841e329b2d92196c151bed65f2ae1f7 Mon Sep 17 00:00:00 2001 From: fredj Date: Wed, 15 Feb 2012 12:32:25 +0100 Subject: [PATCH 58/91] Simplify parent call (don't use intermediate array) --- lib/OpenLayers/Layer/XYZ.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Layer/XYZ.js b/lib/OpenLayers/Layer/XYZ.js index 4c2bfc051d..cc52d97fc6 100644 --- a/lib/OpenLayers/Layer/XYZ.js +++ b/lib/OpenLayers/Layer/XYZ.js @@ -75,10 +75,9 @@ OpenLayers.Layer.XYZ = OpenLayers.Class(OpenLayers.Layer.Grid, { options.projection = new OpenLayers.Projection('EPSG:900913'); options.numZoomLevels = 19; } - url = url || this.url; - name = name || this.name; - var newArguments = [name, url, {}, options]; - OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); + OpenLayers.Layer.Grid.prototype.initialize.apply(this, [ + name || this.name, url || this.url, {}, options + ]); }, /** From 147b32b7e34f18996f79437f7b80f512aba46515 Mon Sep 17 00:00:00 2001 From: fredj Date: Wed, 15 Feb 2012 12:33:14 +0100 Subject: [PATCH 59/91] Don't compute limit if it's not needed --- lib/OpenLayers/Layer/XYZ.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Layer/XYZ.js b/lib/OpenLayers/Layer/XYZ.js index cc52d97fc6..43535dff79 100644 --- a/lib/OpenLayers/Layer/XYZ.js +++ b/lib/OpenLayers/Layer/XYZ.js @@ -147,10 +147,9 @@ OpenLayers.Layer.XYZ = OpenLayers.Class(OpenLayers.Layer.Grid, { OpenLayers.Util.indexOf(resolutions, res) : this.getServerZoom() + this.zoomOffset; - var limit = Math.pow(2, z); - if (this.wrapDateLine) - { - x = ((x % limit) + limit) % limit; + if (this.wrapDateLine) { + var limit = Math.pow(2, z); + x = ((x % limit) + limit) % limit; } return {'x': x, 'y': y, 'z': z}; From 2e423df3d238a4dca6a7c4c1d6bda981aa57257e Mon Sep 17 00:00:00 2001 From: ahocevar Date: Wed, 15 Feb 2012 13:41:25 +0100 Subject: [PATCH 60/91] Use the layer's projection. In setMap, the layer gets the map's projection if it doesn't have its own. And since a layer can have a different SRS code than the map (but a compatible one, i.e. with OpenLayers.Projection.transforms[mapProj][layerProj] being OpenLayer.Projection.nullTransform), the axis order can be different. --- lib/OpenLayers/Layer/WMS.js | 2 +- tests/Control/WMSGetFeatureInfo.html | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/OpenLayers/Layer/WMS.js b/lib/OpenLayers/Layer/WMS.js index 6a283b2a61..2de8a95966 100644 --- a/lib/OpenLayers/Layer/WMS.js +++ b/lib/OpenLayers/Layer/WMS.js @@ -175,7 +175,7 @@ OpenLayers.Layer.WMS = OpenLayers.Class(OpenLayers.Layer.Grid, { * {Boolean} true if the axis order is reversed, false otherwise. */ reverseAxisOrder: function() { - var projCode = this.map.getProjectionObject().getCode(); + var projCode = this.projection.getCode(); return parseFloat(this.params.VERSION) >= 1.3 && !!(this.yx[projCode] || OpenLayers.Projection.defaults[projCode].yx); }, diff --git a/tests/Control/WMSGetFeatureInfo.html b/tests/Control/WMSGetFeatureInfo.html index 7bdbc05625..5e7801b036 100644 --- a/tests/Control/WMSGetFeatureInfo.html +++ b/tests/Control/WMSGetFeatureInfo.html @@ -290,19 +290,19 @@ function test_mixedParams(t) { t.plan(5); var map = new OpenLayers.Map("map", { - getExtent: function() {return(new OpenLayers.Bounds(-180,-90,180,90));}, - getProjectionObject: function() {return new OpenLayers.Projection("EPSG:4326");} + getExtent: function() {return(new OpenLayers.Bounds(-180,-90,180,90));} }); + var geographic = new OpenLayers.Projection("EPSG:4326"); var a = new OpenLayers.Layer.WMS("dummy","http://localhost/wms", { layers: "a,b,c,d", styles: "a,b,c,d" - }, {map: map}); + }, {projection: geographic}); var b = new OpenLayers.Layer.WMS("dummy","http://localhost/wms", { layers: ["a","b","c","d"], styles: ["a","b","c","d"] - }, {map: map}); + }, {projection: geographic}); var c = new OpenLayers.Layer.WMS("dummy","http://localhost/wms", { layers: ["a","b","c","d"] @@ -310,13 +310,13 @@ var d = new OpenLayers.Layer.WMS("dummy","http://localhost/wms", { layers: "a,b,c,d" - }, {map: map}); + }, {projection: geographic}); var click = new OpenLayers.Control.WMSGetFeatureInfo({ featureType: 'type', featureNS: 'ns', layers: [a, b, c, d] - }, {map: map}); + }, {projection: geographic}); map.addControl(click); From 262e2d5bc045d18b297e0a2bd96d8a0562fd9887 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Wed, 15 Feb 2012 21:07:48 +0100 Subject: [PATCH 61/91] Calculating maxResolution instead of having it in defaults. --- lib/OpenLayers/Layer.js | 20 ++++++++++++-------- lib/OpenLayers/Map.js | 4 ++-- lib/OpenLayers/Projection.js | 12 ++++-------- tests/Layer/WMS.html | 1 + tests/Layer/WMTS.html | 6 ++++-- tests/Layer/XYZ.html | 4 ++-- 6 files changed, 25 insertions(+), 22 deletions(-) diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js index ebeb0d3101..6b702a2104 100644 --- a/lib/OpenLayers/Layer.js +++ b/lib/OpenLayers/Layer.js @@ -255,8 +255,8 @@ OpenLayers.Layer = OpenLayers.Class({ * APIProperty: maxResolution * {Float} Default max is 360 deg / 256 px, which corresponds to * zoom level 0 on gmaps. Specify a different value in the layer - * options if you are not using a geographic projection and - * displaying the whole world. + * options if you are not using the default + * and displaying the whole world. */ maxResolution: null, @@ -638,12 +638,6 @@ OpenLayers.Layer = OpenLayers.Class({ this.units || this.map.units; this.initResolutions(); - if (!this.resolutions) { - throw( - "Could not calculate resolutions for layer " + this.name + - ". Configure maxResolution or resolutions or scales." - ); - } if (!this.isBaseLayer) { this.inRange = this.calculateInRange(); @@ -896,6 +890,16 @@ OpenLayers.Layer = OpenLayers.Class({ props.resolutions = this.resolutionsFromScales(props.scales); } 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); } } diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index cae77fe722..24ecd23a1a 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -274,8 +274,8 @@ OpenLayers.Map = OpenLayers.Class({ /** * APIProperty: maxResolution - * {Float} Specify if you are not using a geographic projection or Web - * Mercator and displaying the whole world. + * {Float} Required if you are not displaying the whole world on a tile + * with the size specified in . */ maxResolution: null, diff --git a/lib/OpenLayers/Projection.js b/lib/OpenLayers/Projection.js index 21f4ad2ec2..47b1dcabaa 100644 --- a/lib/OpenLayers/Projection.js +++ b/lib/OpenLayers/Projection.js @@ -167,26 +167,22 @@ OpenLayers.Projection.transforms = {}; * {Object} Defaults for the SRS codes known to OpenLayers (currently * EPSG:4326, CRS:84, urn:ogc:def:crs:EPSG:6.6:4326, EPSG:900913, EPSG:3857, * EPSG:102113 and EPSG:102100). Keys are the SRS code, values are units, - * maxExtent (the validity extent for the SRS), maxResolution (the maximum - * resolution commonly used in grid sets for this SRS) and yx (true if this - * SRS is known to have a reverse axis order). + * maxExtent (the validity extent for the SRS) and yx (true if this SRS is + * known to have a reverse axis order). */ OpenLayers.Projection.defaults = { "EPSG:4326": { units: "degrees", maxExtent: [-180, -90, 180, 90], - maxResolution: 1.40625, yx: true }, "CRS:84": { units: "degrees", - maxExtent: [-180, -90, 180, 90], - maxResolution: 1.40625 + maxExtent: [-180, -90, 180, 90] }, "EPSG:900913": { units: "m", - maxExtent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34], - maxResolution: 156543.03390625 + maxExtent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34] } }; diff --git a/tests/Layer/WMS.html b/tests/Layer/WMS.html index 1459a26e1c..c83103faa7 100644 --- a/tests/Layer/WMS.html +++ b/tests/Layer/WMS.html @@ -388,6 +388,7 @@ var map = new OpenLayers.Map({ div: "map", maxExtent: new OpenLayers.Bounds(-185, -95, 185, 95), + maxResolution: 1.40625, layers: [dummy, unconstrained, constrained], center: new OpenLayers.LonLat(0, 0), zoom: 1 diff --git a/tests/Layer/WMTS.html b/tests/Layer/WMTS.html index e2b64f2604..e8d7a235f1 100644 --- a/tests/Layer/WMTS.html +++ b/tests/Layer/WMTS.html @@ -136,7 +136,8 @@ layer: "world", style: "blue_marble", matrixSet: "arcgis_online", - tileSize: new OpenLayers.Size(512, 512), + tileSize: new OpenLayers.Size(512, 512), + maxResolution: 1.40625, requestEncoding: "REST" }); map.addLayer(layer1); @@ -156,7 +157,8 @@ layer: "world", style: "blue_marble", matrixSet: "arcgis_online", - tileSize: new OpenLayers.Size(512, 512), + tileSize: new OpenLayers.Size(512, 512), + maxResolution: 1.40625, requestEncoding: "REST" }); map.addLayer(layer1); diff --git a/tests/Layer/XYZ.html b/tests/Layer/XYZ.html index 98836106a3..bd6d26ea45 100644 --- a/tests/Layer/XYZ.html +++ b/tests/Layer/XYZ.html @@ -195,7 +195,7 @@ var map = new OpenLayers.Map({ div: "map", - maxResolution: OpenLayers.Projection.defaults["EPSG:4326"].maxResolution / Math.pow(2, offset) + maxResolution: 1.40625 / Math.pow(2, offset) }); var layer = new OpenLayers.Layer.XYZ(name, url, {zoomOffset: offset}); map.addLayer(layer); @@ -211,7 +211,7 @@ var map = new OpenLayers.Map({ div: "map", - maxResolution: OpenLayers.Projection.defaults["EPSG:4326"].maxResolution / Math.pow(2, offset) + maxResolution: 1.40625 / Math.pow(2, offset) }); var layer = new OpenLayers.Layer.XYZ(name, url, {zoomOffset: offset}); map.addLayer(layer); From 6b8ba43e20cb85d09a72e4e4bce8547c41e46e75 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Wed, 15 Feb 2012 22:00:54 +0100 Subject: [PATCH 62/91] Adding a scaled layer. --- examples/google-static.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/examples/google-static.js b/examples/google-static.js index dde0903ea8..af6f1cc688 100644 --- a/examples/google-static.js +++ b/examples/google-static.js @@ -40,7 +40,23 @@ var map = new OpenLayers.Map({ "Google Satellite", "http://maps.googleapis.com/maps/api/staticmap?sensor=false&maptype=satellite", null, options - ) + ), + // the same layer again, but scaled to allow map sizes up to 1280x1280 pixels + new OpenLayers.Layer.Grid( + "Google Satellite (scale=2)", + "http://maps.googleapis.com/maps/api/staticmap?sensor=false&maptype=satellite&scale=2", + null, OpenLayers.Util.applyDefaults({ + getURL: function() { + var center = this.map.getCenter().transform("EPSG:3857", "EPSG:4326"), + size = this.map.getSize(); + return [ + this.url, "¢er=", center.lat, ",", center.lon, + "&zoom=", (this.map.getZoom() - 1), + "&size=", Math.floor(size.w / 2), "x", Math.floor(size.h / 2) + ].join(""); + } + }, options) + ), ], center: new OpenLayers.LonLat(10.2, 48.9).transform("EPSG:4326", "EPSG:3857"), zoom: 5 From 30ad3adb9df07ae1b27e6fa51e739ca5379d007f Mon Sep 17 00:00:00 2001 From: _DR_ Date: Thu, 16 Feb 2012 08:50:17 +0400 Subject: [PATCH 63/91] Fix Basic ESRI Map Cache Example --- examples/xyz-esri.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/xyz-esri.html b/examples/xyz-esri.html index f6855a52ed..71ad270134 100644 --- a/examples/xyz-esri.html +++ b/examples/xyz-esri.html @@ -19,7 +19,7 @@ var layerExtent = new OpenLayers.Bounds( -13758743.4295939, 5591455.28887228, -13531302.3472101 , 5757360.4178881); map = new OpenLayers.Map( 'map', {'restrictedExtent': layerExtent} ); layer = new OpenLayers.Layer.XYZ( "ESRI", - "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Portland/ESRI_LandBase_WebMercator/MapServer/tile/${z}/${y}/${x}", + "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/${z}/${y}/${x}", {sphericalMercator: true} ); map.addLayer(layer); map.zoomToExtent(map.restrictedExtent); @@ -33,7 +33,7 @@ XYZ, layer, tile -

    Show a Simple ESRI map using the layer from ESRI's server.
    +
    Show a Simple ESRI map using the layer from ESRI's server.
    From 1cc8770476f56ea1012d5afe6cf9aa25319c3dc9 Mon Sep 17 00:00:00 2001 From: fredj Date: Thu, 16 Feb 2012 09:20:41 +0100 Subject: [PATCH 64/91] Use OpenLayers.Projection.defaults values. --- examples/canvas.js | 7 +------ examples/clientzoom.js | 4 ---- examples/mobile-base.js | 5 ----- examples/mobile-drawing.js | 5 ----- examples/mobile-navigation.js | 5 ----- examples/osm-google.js | 7 +------ examples/overviewmap.html | 3 +-- examples/sundials-spherical-mercator.html | 6 +----- examples/wfs-protocol-transactions.js | 3 --- examples/wfs-reprojection.js | 7 +------ examples/wmts-capabilities.js | 7 +------ examples/wmts-getfeatureinfo.js | 7 +------ examples/wmts.js | 7 +------ 13 files changed, 8 insertions(+), 65 deletions(-) diff --git a/examples/canvas.js b/examples/canvas.js index 6440c39a11..bb2f224f60 100644 --- a/examples/canvas.js +++ b/examples/canvas.js @@ -5,12 +5,7 @@ function init() { map = new OpenLayers.Map({ div: "map", projection: new OpenLayers.Projection("EPSG:900913"), - displayProjection: new OpenLayers.Projection("EPSG:4326"), - units: "m", - maxResolution: 156543.0339, - maxExtent: new OpenLayers.Bounds( - -20037508, -20037508, 20037508, 20037508 - ) + displayProjection: new OpenLayers.Projection("EPSG:4326") }); var g = new OpenLayers.Layer.Google("Google Layer", { diff --git a/examples/clientzoom.js b/examples/clientzoom.js index 65ae758c3c..30071edfef 100644 --- a/examples/clientzoom.js +++ b/examples/clientzoom.js @@ -5,10 +5,6 @@ function init() { map = new OpenLayers.Map({ div: "map", projection: "EPSG:900913", - units: "m", - maxExtent: new OpenLayers.Bounds( - -20037508.34, -20037508.34, 20037508.34, 20037508.34 - ), controls: [], fractionalZoom: true }); diff --git a/examples/mobile-base.js b/examples/mobile-base.js index 5e123cc3b9..5440f932e2 100644 --- a/examples/mobile-base.js +++ b/examples/mobile-base.js @@ -41,12 +41,7 @@ var init = function (onSelectFeatureFunction) { div: "map", theme: null, projection: sm, - units: "m", numZoomLevels: 18, - maxResolution: 156543.0339, - maxExtent: new OpenLayers.Bounds( - -20037508.34, -20037508.34, 20037508.34, 20037508.34 - ), controls: [ new OpenLayers.Control.Attribution(), new OpenLayers.Control.TouchNavigation({ diff --git a/examples/mobile-drawing.js b/examples/mobile-drawing.js index 34b26ec30f..13494ef321 100644 --- a/examples/mobile-drawing.js +++ b/examples/mobile-drawing.js @@ -41,12 +41,7 @@ function init() { map = new OpenLayers.Map({ div: 'map', projection: 'EPSG:900913', - units: 'm', numZoomLevels: 18, - maxResolution: 156543.0339, - maxExtent: new OpenLayers.Bounds( - -20037508.34, -20037508.34, 20037508.34, 20037508.34 - ), controls: [ new OpenLayers.Control.TouchNavigation({ dragPanOptions: { diff --git a/examples/mobile-navigation.js b/examples/mobile-navigation.js index ce08b498e6..57929e9de3 100644 --- a/examples/mobile-navigation.js +++ b/examples/mobile-navigation.js @@ -5,12 +5,7 @@ function init() { div: "map", theme: null, projection: new OpenLayers.Projection("EPSG:900913"), - units: "m", numZoomLevels: 18, - maxResolution: 156543.0339, - maxExtent: new OpenLayers.Bounds( - -20037508.34, -20037508.34, 20037508.34, 20037508.34 - ), controls: [ new OpenLayers.Control.TouchNavigation({ dragPanOptions: { diff --git a/examples/osm-google.js b/examples/osm-google.js index 77d96d82f4..aaa823395f 100644 --- a/examples/osm-google.js +++ b/examples/osm-google.js @@ -3,12 +3,7 @@ var map; function init() { map = new OpenLayers.Map({ div: "map", - projection: new OpenLayers.Projection("EPSG:900913"), - units: "m", - maxResolution: 156543.0339, - maxExtent: new OpenLayers.Bounds( - -20037508, -20037508, 20037508, 20037508.34 - ) + projection: new OpenLayers.Projection("EPSG:900913") }); var osm = new OpenLayers.Layer.OSM(); diff --git a/examples/overviewmap.html b/examples/overviewmap.html index 2cb9df9fc9..165c987e8b 100644 --- a/examples/overviewmap.html +++ b/examples/overviewmap.html @@ -91,8 +91,7 @@ maxExtent: new OpenLayers.Bounds(-8242894.927728, 4965204.031195, -8227290.161511, 4994963.723637), maxResolution: 116.24879860156216, - projection: "EPSG:900913", - units: "m" + projection: "EPSG:900913" }; var map2 = new OpenLayers.Map('map2', mapOptions); diff --git a/examples/sundials-spherical-mercator.html b/examples/sundials-spherical-mercator.html index 38f7b9321f..3ee614483f 100644 --- a/examples/sundials-spherical-mercator.html +++ b/examples/sundials-spherical-mercator.html @@ -31,11 +31,7 @@ function init(){ var options = { projection: new OpenLayers.Projection("EPSG:900913"), - displayProjection: new OpenLayers.Projection("EPSG:4326"), - units: "m", - maxResolution: 156543.0339, - maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, - 20037508.34, 20037508.34) + displayProjection: new OpenLayers.Projection("EPSG:4326") }; map = new OpenLayers.Map('map', options); var mapnik = new OpenLayers.Layer.OSM("OpenStreetMap (Mapnik)"); diff --git a/examples/wfs-protocol-transactions.js b/examples/wfs-protocol-transactions.js index 1f61958fe2..6b1044edcf 100644 --- a/examples/wfs-protocol-transactions.js +++ b/examples/wfs-protocol-transactions.js @@ -38,9 +38,6 @@ function init() { map = new OpenLayers.Map('map', { projection: new OpenLayers.Projection("EPSG:900913"), displayProjection: new OpenLayers.Projection("EPSG:4326"), - units: "m", - maxResolution: 20037508.34 / 128, - maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508), restrictedExtent: extent, controls: [ new OpenLayers.Control.PanZoom(), diff --git a/examples/wfs-reprojection.js b/examples/wfs-reprojection.js index d789b929b8..64a07367a2 100644 --- a/examples/wfs-reprojection.js +++ b/examples/wfs-reprojection.js @@ -7,12 +7,7 @@ function init() { var mercator = new OpenLayers.Projection("EPSG:900913"); map = new OpenLayers.Map('map', { - projection: mercator, - units: "m", - maxResolution: 156543.0339, - maxExtent: new OpenLayers.Bounds( - -20037508, -20037508, 20037508, 20037508 - ) + projection: mercator }); var g = new OpenLayers.Layer.Google("Google Layer", { diff --git a/examples/wmts-capabilities.js b/examples/wmts-capabilities.js index 27fa54a9c3..dc12941058 100644 --- a/examples/wmts-capabilities.js +++ b/examples/wmts-capabilities.js @@ -47,12 +47,7 @@ function init() { map = new OpenLayers.Map({ div: "map", - projection: "EPSG:900913", - units: "m", - maxExtent: new OpenLayers.Bounds( - -20037508.34, -20037508.34, 20037508.34, 20037508.34 - ), - maxResolution: 156543.0339 + projection: "EPSG:900913" }); var osm = new OpenLayers.Layer.OSM(); diff --git a/examples/wmts-getfeatureinfo.js b/examples/wmts-getfeatureinfo.js index b2c949cdea..0b8cd8a627 100644 --- a/examples/wmts-getfeatureinfo.js +++ b/examples/wmts-getfeatureinfo.js @@ -5,12 +5,7 @@ function init() { map = new OpenLayers.Map({ div: "map", - projection: "EPSG:900913", - units: "m", - maxExtent: new OpenLayers.Bounds( - -20037508.34, -20037508.34, 20037508.34, 20037508.34 - ), - maxResolution: 156543.0339 + projection: "EPSG:900913" }); var osm = new OpenLayers.Layer.OSM(); diff --git a/examples/wmts.js b/examples/wmts.js index 784e596b53..391a20030e 100644 --- a/examples/wmts.js +++ b/examples/wmts.js @@ -4,12 +4,7 @@ function init() { map = new OpenLayers.Map({ div: "map", - projection: "EPSG:900913", - units: "m", - maxExtent: new OpenLayers.Bounds( - -20037508.34, -20037508.34, 20037508.34, 20037508.34 - ), - maxResolution: 156543.0339 + projection: "EPSG:900913" }); var osm = new OpenLayers.Layer.OSM(); From b3ad2410559970250f3f923908d5867f9e446084 Mon Sep 17 00:00:00 2001 From: fredj Date: Thu, 16 Feb 2012 09:42:46 +0100 Subject: [PATCH 65/91] Use jQuery Mobile 1.0.1 Release --- examples/mobile-jq.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/mobile-jq.html b/examples/mobile-jq.html index eb9ff6c7c2..470fd39d5d 100644 --- a/examples/mobile-jq.html +++ b/examples/mobile-jq.html @@ -7,7 +7,7 @@ - + From 0727f5558ac26e0571500f604e7222760ac70be4 Mon Sep 17 00:00:00 2001 From: fredj Date: Thu, 16 Feb 2012 13:55:53 +0100 Subject: [PATCH 66/91] Remove maxExtent, maxResolution and units options. See #219 --- examples/google-static.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/google-static.js b/examples/google-static.js index af6f1cc688..bc97e4c0bb 100644 --- a/examples/google-static.js +++ b/examples/google-static.js @@ -15,9 +15,6 @@ var options = { var map = new OpenLayers.Map({ div: "map", - maxExtent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34], - maxResolution: 156543.03390625, - units: "m", projection: "EPSG:3857", numZoomLevels: 22, layers: [ From 584d33eaa33ac914d9fbf8bc9b36e76bd9b00b2c Mon Sep 17 00:00:00 2001 From: Peter Robins Date: Thu, 16 Feb 2012 13:32:10 +0000 Subject: [PATCH 67/91] GPX read should allow for blank attribute nodes --- lib/OpenLayers/Format/GPX.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/OpenLayers/Format/GPX.js b/lib/OpenLayers/Format/GPX.js index 8da76193d2..2b71d3b27d 100644 --- a/lib/OpenLayers/Format/GPX.js +++ b/lib/OpenLayers/Format/GPX.js @@ -197,7 +197,7 @@ OpenLayers.Format.GPX = OpenLayers.Class(OpenLayers.Format.XML, { var attributes = {}; var attrNode = node.firstChild, value, name; while(attrNode) { - if(attrNode.nodeType == 1) { + if(attrNode.nodeType == 1 && attrNode.firstChild) { value = attrNode.firstChild; if(value.nodeType == 3 || value.nodeType == 4) { name = (attrNode.prefix) ? From 17f96f68a208cc2941a197e0d80dc0f1ba9f4b06 Mon Sep 17 00:00:00 2001 From: fredj Date: Thu, 16 Feb 2012 15:09:11 +0100 Subject: [PATCH 68/91] Preserve numZoomLevels from options. r=@tonio (see #219) --- lib/OpenLayers/Layer/XYZ.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Layer/XYZ.js b/lib/OpenLayers/Layer/XYZ.js index 43535dff79..b2cdefd3d2 100644 --- a/lib/OpenLayers/Layer/XYZ.js +++ b/lib/OpenLayers/Layer/XYZ.js @@ -70,10 +70,11 @@ OpenLayers.Layer.XYZ = OpenLayers.Class(OpenLayers.Layer.Grid, { * options - {Object} Hashtable of extra options to tag onto the layer */ initialize: function(name, url, options) { - options = options || {}; - if (options.sphericalMercator || this.sphericalMercator) { - options.projection = new OpenLayers.Projection('EPSG:900913'); - options.numZoomLevels = 19; + if (options && options.sphericalMercator || this.sphericalMercator) { + options = OpenLayers.Util.extend({ + projection: "EPSG:900913", + numZoomLevels: 19 + }, options); } OpenLayers.Layer.Grid.prototype.initialize.apply(this, [ name || this.name, url || this.url, {}, options From 93e4d0b94c57cf8a2d32f25570f38be9d973c820 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Thu, 16 Feb 2012 16:29:06 +0100 Subject: [PATCH 69/91] Making loaded tile available to tileloaded listeners. --- lib/OpenLayers/Layer/Grid.js | 6 ++++-- tests/Layer/Grid.html | 15 ++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index a58c7e7ce2..1e767f75dd 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -199,7 +199,9 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { * tileloaded - Triggered when each new tile is * loaded, as a means of progress update to listeners. * listeners can access 'numLoadingTiles' if they wish to keep - * track of the loading progress. + * track of the loading progress. Listeners are called with an object + * with a tile property as first argument, making the loded tile + * available to the listener. */ /** @@ -971,7 +973,7 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { tile.onLoadEnd = function() { this.numLoadingTiles--; - this.events.triggerEvent("tileloaded"); + this.events.triggerEvent("tileloaded", {tile: tile}); //if that was the last tile, then trigger a 'loadend' on the layer if (this.tileQueue.length === 0 && this.numLoadingTiles === 0) { this.events.triggerEvent("loadend"); diff --git a/tests/Layer/Grid.html b/tests/Layer/Grid.html index 34478df73d..366627caa3 100644 --- a/tests/Layer/Grid.html +++ b/tests/Layer/Grid.html @@ -505,12 +505,12 @@ } function test_Layer_Grid_addTileMonitoringHooks(t) { - t.plan(14); + t.plan(15); layer = new OpenLayers.Layer.Grid(); layer.events = { - 'triggerEvent': function(str) { - g_events.push(str); + 'triggerEvent': function(str, evt) { + g_events.push([str, evt]); } } @@ -536,7 +536,7 @@ g_events = []; tile.onLoadStart.apply(layer); - t.eq(g_events[0], "loadstart", "loadstart event triggered when numLoadingTiles is 0"); + t.eq(g_events[0][0], "loadstart", "loadstart event triggered when numLoadingTiles is 0"); t.eq(layer.numLoadingTiles, 1, "numLoadingTiles incremented"); g_events = []; @@ -553,7 +553,8 @@ layer.numLoadingTiles = 2; g_events = []; tile.onLoadEnd.apply(layer); - t.eq(g_events[0], "tileloaded", "tileloaded triggered when numLoadingTiles is > 0"); + t.eq(g_events[0][0], "tileloaded", "tileloaded triggered when numLoadingTiles is > 0"); + t.ok(g_events[0][1].tile === tile, "tile passed as tile property to event object"); t.eq(g_events.length, 1, "loadend event not triggered when numLoadingTiles is > 0"); t.eq(layer.numLoadingTiles, 1, "numLoadingTiles decremented"); @@ -561,8 +562,8 @@ g_events = []; layer.grid = [[{}]]; // to prevent error in updateBackBuffer tile.onLoadEnd.apply(layer); - t.eq(g_events[0], "tileloaded", "tileloaded triggered when numLoadingTiles is 0"); - t.eq(g_events[1], "loadend", "loadend event triggered when numLoadingTiles is 0"); + t.eq(g_events[0][0], "tileloaded", "tileloaded triggered when numLoadingTiles is 0"); + t.eq(g_events[1][0], "loadend", "loadend event triggered when numLoadingTiles is 0"); t.eq(layer.numLoadingTiles, 0, "numLoadingTiles decremented"); } From 2b5ade2dde3089addb8ba6a48226f76aef3a5ce4 Mon Sep 17 00:00:00 2001 From: tschaub Date: Thu, 16 Feb 2012 10:36:34 -0700 Subject: [PATCH 70/91] Adding back events documentation. When the list of event types became unconstrained in 501b42228ab12d50f06d8f000dac5078aaca9509, we lost the documentation for events that are triggered. This change adds the list of events triggered to the API docs for events properties. --- lib/OpenLayers/Control.js | 6 +- lib/OpenLayers/Control/DrawFeature.js | 13 +++- lib/OpenLayers/Control/Geolocate.js | 27 +++++--- lib/OpenLayers/Control/GetFeature.js | 13 +++- lib/OpenLayers/Control/Measure.js | 11 ++-- lib/OpenLayers/Control/SLDSelect.js | 12 ++-- lib/OpenLayers/Control/SelectFeature.js | 23 +++++-- lib/OpenLayers/Control/Snapping.js | 11 ++-- lib/OpenLayers/Control/Split.js | 11 ++-- lib/OpenLayers/Control/TransformFeature.js | 63 ++++++++++-------- lib/OpenLayers/Control/WMSGetFeatureInfo.js | 13 +++- lib/OpenLayers/Control/WMTSGetFeatureInfo.js | 13 +++- lib/OpenLayers/Layer.js | 31 +++++---- lib/OpenLayers/Layer/Vector.js | 5 +- lib/OpenLayers/Map.js | 68 ++++++++++---------- lib/OpenLayers/Strategy/Save.js | 12 ++-- lib/OpenLayers/Tile.js | 29 +++++---- 17 files changed, 218 insertions(+), 143 deletions(-) diff --git a/lib/OpenLayers/Control.js b/lib/OpenLayers/Control.js index a91887f869..ac867fc288 100644 --- a/lib/OpenLayers/Control.js +++ b/lib/OpenLayers/Control.js @@ -139,10 +139,7 @@ OpenLayers.Control = OpenLayers.Class({ * APIProperty: events * {} Events instance for listeners and triggering * control specific events. - */ - events: null, - - /** + * * Register a listener for a particular event with the following syntax: * (code) * control.events.register(type, obj, listener); @@ -161,6 +158,7 @@ OpenLayers.Control = OpenLayers.Class({ * activate - Triggered when activated. * deactivate - Triggered when deactivated. */ + events: null, /** * Constructor: OpenLayers.Control diff --git a/lib/OpenLayers/Control/DrawFeature.js b/lib/OpenLayers/Control/DrawFeature.js index e8e2e139ee..d53f7a47f6 100644 --- a/lib/OpenLayers/Control/DrawFeature.js +++ b/lib/OpenLayers/Control/DrawFeature.js @@ -31,8 +31,17 @@ OpenLayers.Control.DrawFeature = OpenLayers.Class(OpenLayers.Control, { */ callbacks: null, - /** - * Supported event types: + /** + * APIProperty: events + * {} Events instance for listeners and triggering + * control specific events. + * + * Register a listener for a particular event with the following syntax: + * (code) + * control.events.register(type, obj, listener); + * (end) + * + * Supported event types (in addition to those from ): * featureadded - Triggered when a feature is added */ diff --git a/lib/OpenLayers/Control/Geolocate.js b/lib/OpenLayers/Control/Geolocate.js index 28b93bb062..aa19c8a9ae 100644 --- a/lib/OpenLayers/Control/Geolocate.js +++ b/lib/OpenLayers/Control/Geolocate.js @@ -22,15 +22,24 @@ */ OpenLayers.Control.Geolocate = OpenLayers.Class(OpenLayers.Control, { - /** - * Supported event types: - * - *locationupdated* Triggered when browser return a new position. Listeners will - * receive an object with a 'position' property which is the browser.geolocation.position - * native object, as well as a 'point' property which is the location transformed in the - * current map projection. - * - *locationfailed* Triggered when geolocation has failed - * - *locationuncapable* Triggered when control is activated on a browser - * which doesn't support geolocation + /** + * APIProperty: events + * {} Events instance for listeners and triggering + * control specific events. + * + * Register a listener for a particular event with the following syntax: + * (code) + * control.events.register(type, obj, listener); + * (end) + * + * Supported event types (in addition to those from ): + * locationupdated - Triggered when browser return a new position. Listeners will + * receive an object with a 'position' property which is the browser.geolocation.position + * native object, as well as a 'point' property which is the location transformed in the + * current map projection. + * locationfailed - Triggered when geolocation has failed + * locationuncapable - Triggered when control is activated on a browser + * which doesn't support geolocation */ /** diff --git a/lib/OpenLayers/Control/GetFeature.js b/lib/OpenLayers/Control/GetFeature.js index 98ac1cfdc8..c037f87d15 100644 --- a/lib/OpenLayers/Control/GetFeature.js +++ b/lib/OpenLayers/Control/GetFeature.js @@ -169,8 +169,17 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, { */ filterType: OpenLayers.Filter.Spatial.BBOX, - /** - * Supported event types: + /** + * APIProperty: events + * {} Events instance for listeners and triggering + * control specific events. + * + * Register a listener for a particular event with the following syntax: + * (code) + * control.events.register(type, obj, listener); + * (end) + * + * Supported event types (in addition to those from ): * beforefeatureselected - Triggered when is true before a * feature is selected. The event object has a feature property with * the feature about to select diff --git a/lib/OpenLayers/Control/Measure.js b/lib/OpenLayers/Control/Measure.js index 59aec5370c..7eb05a02c2 100644 --- a/lib/OpenLayers/Control/Measure.js +++ b/lib/OpenLayers/Control/Measure.js @@ -17,16 +17,17 @@ */ OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, { - /** + /** + * APIProperty: events + * {} Events instance for listeners and triggering + * control specific events. + * * Register a listener for a particular event with the following syntax: * (code) * control.events.register(type, obj, listener); * (end) * - * Listeners will be called with a reference to an event object. The - * properties of this event depends on exactly what happened. - * - * Supported control event types (in addition to those from ): + * Supported event types (in addition to those from ): * measure - Triggered when a measurement sketch is complete. Listeners * will receive an event with measure, units, order, and geometry * properties. diff --git a/lib/OpenLayers/Control/SLDSelect.js b/lib/OpenLayers/Control/SLDSelect.js index c192344a15..52f0798ae9 100644 --- a/lib/OpenLayers/Control/SLDSelect.js +++ b/lib/OpenLayers/Control/SLDSelect.js @@ -23,17 +23,17 @@ */ OpenLayers.Control.SLDSelect = OpenLayers.Class(OpenLayers.Control, { - /** + /** + * APIProperty: events + * {} Events instance for listeners and triggering + * control specific events. + * * Register a listener for a particular event with the following syntax: * (code) * control.events.register(type, obj, listener); * (end) * - * Listeners will be called with a reference to an event object. The - * properties of this event depends on exactly what happened. - * - * Supported control event types (in addition to those from - * ): + * Supported event types (in addition to those from ): * selected - Triggered when a selection occurs. Listeners receive an * event with *filters* and *layer* properties. Filters will be an * array of OpenLayers.Filter objects created in order to perform diff --git a/lib/OpenLayers/Control/SelectFeature.js b/lib/OpenLayers/Control/SelectFeature.js index ab6ac484ab..4753b154d6 100644 --- a/lib/OpenLayers/Control/SelectFeature.js +++ b/lib/OpenLayers/Control/SelectFeature.js @@ -21,13 +21,22 @@ */ OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, { - /** - * Supported event types: - * - *beforefeaturehighlighted* Triggered before a feature is highlighted - * - *featurehighlighted* Triggered when a feature is highlighted - * - *featureunhighlighted* Triggered when a feature is unhighlighted - * - *boxselectionstart* Triggered before box selection starts - * - *boxselectionend* Triggered after box selection ends + /** + * APIProperty: events + * {} Events instance for listeners and triggering + * control specific events. + * + * Register a listener for a particular event with the following syntax: + * (code) + * control.events.register(type, obj, listener); + * (end) + * + * Supported event types (in addition to those from ): + * beforefeaturehighlighted - Triggered before a feature is highlighted + * featurehighlighted - Triggered when a feature is highlighted + * featureunhighlighted - Triggered when a feature is unhighlighted + * boxselectionstart - Triggered before box selection starts + * boxselectionend - Triggered after box selection ends */ /** diff --git a/lib/OpenLayers/Control/Snapping.js b/lib/OpenLayers/Control/Snapping.js index 792f0183a4..a883ee0495 100644 --- a/lib/OpenLayers/Control/Snapping.js +++ b/lib/OpenLayers/Control/Snapping.js @@ -17,16 +17,17 @@ */ OpenLayers.Control.Snapping = OpenLayers.Class(OpenLayers.Control, { - /** + /** + * APIProperty: events + * {} Events instance for listeners and triggering + * control specific events. + * * Register a listener for a particular event with the following syntax: * (code) * control.events.register(type, obj, listener); * (end) * - * Listeners will be called with a reference to an event object. The - * properties of this event depends on exactly what happened. - * - * Supported control event types (in addition to those from ): + * Supported event types (in addition to those from ): * beforesnap - Triggered before a snap occurs. Listeners receive an * event object with *point*, *x*, *y*, *distance*, *layer*, and * *snapType* properties. The point property will be original point diff --git a/lib/OpenLayers/Control/Split.js b/lib/OpenLayers/Control/Split.js index 8439078d60..3aa56fb599 100644 --- a/lib/OpenLayers/Control/Split.js +++ b/lib/OpenLayers/Control/Split.js @@ -18,16 +18,17 @@ */ OpenLayers.Control.Split = OpenLayers.Class(OpenLayers.Control, { - /** + /** + * APIProperty: events + * {} Events instance for listeners and triggering + * control specific events. + * * Register a listener for a particular event with the following syntax: * (code) * control.events.register(type, obj, listener); * (end) * - * Listeners will be called with a reference to an event object. The - * properties of this event depends on exactly what happened. - * - * Supported control event types (in addition to those from ): + * Supported event types (in addition to those from ): * beforesplit - Triggered before a split occurs. Listeners receive an * event object with *source* and *target* properties. * split - Triggered when a split occurs. Listeners receive an event with diff --git a/lib/OpenLayers/Control/TransformFeature.js b/lib/OpenLayers/Control/TransformFeature.js index 2b719a4450..5b84a10ee7 100644 --- a/lib/OpenLayers/Control/TransformFeature.js +++ b/lib/OpenLayers/Control/TransformFeature.js @@ -21,33 +21,42 @@ */ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, { - /** - * Supported event types: - * - *beforesetfeature* Triggered before a feature is set for - * tranformation. The feature will not be set if a listener returns - * false. Listeners receive a *feature* property, with the feature - * that will be set for transformation. Listeners are allowed to - * set the control's *scale*, *ratio* and *rotation* properties, - * which will set the initial scale, ratio and rotation of the - * feature, like the method's initialParams argument. - * - *setfeature* Triggered when a feature is set for tranformation. - * Listeners receive a *feature* property, with the feature that - * is now set for transformation. - * - *beforetransform* Triggered while dragging, before a feature is - * transformed. The feature will not be transformed if a listener - * returns false (but the box still will). Listeners receive one or - * more of *center*, *scale*, *ratio* and *rotation*. The *center* - * property is an object with the new - * center of the transformed feature, the others are Floats with the - * scale, ratio or rotation change since the last transformation. - * - *transform* Triggered while dragging, when a feature is transformed. - * Listeners receive an event object with one or more of *center*, - * *scale*, *ratio* and *rotation*. The *center* property is an - * object with the new center of the - * transformed feature, the others are Floats with the scale, ratio - * or rotation change of the feature since the last transformation. - * - *transformcomplete* Triggered after dragging. Listeners receive - * an event object with the transformed *feature*. + /** + * APIProperty: events + * {} Events instance for listeners and triggering + * control specific events. + * + * Register a listener for a particular event with the following syntax: + * (code) + * control.events.register(type, obj, listener); + * (end) + * + * Supported event types (in addition to those from ): + * beforesetfeature - Triggered before a feature is set for + * tranformation. The feature will not be set if a listener returns + * false. Listeners receive a *feature* property, with the feature + * that will be set for transformation. Listeners are allowed to + * set the control's *scale*, *ratio* and *rotation* properties, + * which will set the initial scale, ratio and rotation of the + * feature, like the method's initialParams argument. + * setfeature - Triggered when a feature is set for tranformation. + * Listeners receive a *feature* property, with the feature that + * is now set for transformation. + * beforetransform - Triggered while dragging, before a feature is + * transformed. The feature will not be transformed if a listener + * returns false (but the box still will). Listeners receive one or + * more of *center*, *scale*, *ratio* and *rotation*. The *center* + * property is an object with the new + * center of the transformed feature, the others are Floats with the + * scale, ratio or rotation change since the last transformation. + * transform - Triggered while dragging, when a feature is transformed. + * Listeners receive an event object with one or more of *center*, + * scale*, *ratio* and *rotation*. The *center* property is an + * object with the new center of the + * transformed feature, the others are Floats with the scale, ratio + * or rotation change of the feature since the last transformation. + * transformcomplete - Triggered after dragging. Listeners receive + * an event object with the transformed *feature*. */ /** diff --git a/lib/OpenLayers/Control/WMSGetFeatureInfo.js b/lib/OpenLayers/Control/WMSGetFeatureInfo.js index 6aac4b01a8..9348a9d542 100644 --- a/lib/OpenLayers/Control/WMSGetFeatureInfo.js +++ b/lib/OpenLayers/Control/WMSGetFeatureInfo.js @@ -154,8 +154,17 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, { */ hoverRequest: null, - /** - * Supported event types (in addition to those from ): + /** + * APIProperty: events + * {} Events instance for listeners and triggering + * control specific events. + * + * Register a listener for a particular event with the following syntax: + * (code) + * control.events.register(type, obj, listener); + * (end) + * + * Supported event types (in addition to those from ): * beforegetfeatureinfo - Triggered before the request is sent. * The event object has an *xy* property with the position of the * mouse click or hover event that triggers the request. diff --git a/lib/OpenLayers/Control/WMTSGetFeatureInfo.js b/lib/OpenLayers/Control/WMTSGetFeatureInfo.js index e2004318f7..1622abebab 100644 --- a/lib/OpenLayers/Control/WMTSGetFeatureInfo.js +++ b/lib/OpenLayers/Control/WMTSGetFeatureInfo.js @@ -135,8 +135,17 @@ OpenLayers.Control.WMTSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, { */ hoverRequest: null, - /** - * Supported event types (in addition to those from ): + /** + * APIProperty: events + * {} Events instance for listeners and triggering + * control specific events. + * + * Register a listener for a particular event with the following syntax: + * (code) + * control.events.register(type, obj, listener); + * (end) + * + * Supported event types (in addition to those from ): * beforegetfeatureinfo - Triggered before each request is sent. * The event object has an *xy* property with the position of the * mouse click or hover event that triggers the request and a *layer* diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js index 6b702a2104..d543f66e90 100644 --- a/lib/OpenLayers/Layer.js +++ b/lib/OpenLayers/Layer.js @@ -58,6 +58,21 @@ OpenLayers.Layer = OpenLayers.Class({ alwaysInRange: null, /** + * Constant: RESOLUTION_PROPERTIES + * {Array} The properties that are used for calculating resolutions + * information. + */ + RESOLUTION_PROPERTIES: [ + 'scales', 'resolutions', + 'maxScale', 'minScale', + 'maxResolution', 'minResolution', + 'numZoomLevels', 'maxZoomLevel' + ], + + /** + * APIProperty: events + * {} + * * Register a listener for a particular event with the following syntax: * (code) * layer.events.register(type, obj, listener); @@ -87,22 +102,6 @@ OpenLayers.Layer = OpenLayers.Class({ * will receive an object with a *map* property referencing the map and * a *layer* property referencing the layer. */ - - /** - * Constant: RESOLUTION_PROPERTIES - * {Array} The properties that are used for calculating resolutions - * information. - */ - RESOLUTION_PROPERTIES: [ - 'scales', 'resolutions', - 'maxScale', 'minScale', - 'maxResolution', 'minResolution', - 'numZoomLevels', 'maxZoomLevel' - ], - - /** - * APIProperty: events - * {} */ events: null, diff --git a/lib/OpenLayers/Layer/Vector.js b/lib/OpenLayers/Layer/Vector.js index baefdad89e..2857a82d7b 100644 --- a/lib/OpenLayers/Layer/Vector.js +++ b/lib/OpenLayers/Layer/Vector.js @@ -24,6 +24,9 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, { /** + * APIProperty: events + * {} + * * Register a listener for a particular event with the following syntax: * (code) * layer.events.register(type, obj, listener); @@ -36,7 +39,7 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, { * object - {Object} A reference to layer.events.object. * element - {DOMElement} A reference to layer.events.element. * - * Supported map event types (in addition to those from ): + * Supported map event types (in addition to those from ): * beforefeatureadded - Triggered before a feature is added. Listeners * will receive an object with a *feature* property referencing the * feature to be added. To stop the feature from being added, a diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 24ecd23a1a..393e8129ba 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -35,6 +35,9 @@ OpenLayers.Map = OpenLayers.Class({ }, /** + * APIProperty: events + * {} + * * Register a listener for a particular event with the following syntax: * (code) * map.events.register(type, obj, listener); @@ -44,43 +47,42 @@ OpenLayers.Map = OpenLayers.Class({ * properties of this event depends on exactly what happened. * * All event objects have at least the following properties: - * - *object* {Object} A reference to map.events.object. - * - *element* {DOMElement} A reference to map.events.element. + * object - {Object} A reference to map.events.object. + * element - {DOMElement} A reference to map.events.element. * * Browser events have the following additional properties: - * - *xy* {} The pixel location of the event (relative - * to the the map viewport). - * - other properties that come with browser events + * xy - {} The pixel location of the event (relative + * to the the map viewport). * * Supported map event types: - * - *preaddlayer* triggered before a layer has been added. The event - * object will include a *layer* property that references the layer - * to be added. When a listener returns "false" the adding will be - * aborted. - * - *addlayer* triggered after a layer has been added. The event object - * will include a *layer* property that references the added layer. - * - *preremovelayer* triggered before a layer has been removed. The event - * object will include a *layer* property that references the layer - * to be removed. When a listener returns "false" the removal will be - * aborted. - * - *removelayer* triggered after a layer has been removed. The event - * object will include a *layer* property that references the removed - * layer. - * - *changelayer* triggered after a layer name change, order change, - * opacity change, params change, visibility change (due to resolution - * thresholds) or attribution change (due to extent change). Listeners - * will receive an event object with *layer* and *property* properties. - * The *layer* property will be a reference to the changed layer. The - * *property* property will be a key to the changed property (name, - * order, opacity, params, visibility or attribution). - * - *movestart* triggered after the start of a drag, pan, or zoom - * - *move* triggered after each drag, pan, or zoom - * - *moveend* triggered after a drag, pan, or zoom completes - * - *zoomend* triggered after a zoom completes - * - *mouseover* triggered after mouseover the map - * - *mouseout* triggered after mouseout the map - * - *mousemove* triggered after mousemove the map - * - *changebaselayer* triggered after the base layer changes + * preaddlayer - triggered before a layer has been added. The event + * object will include a *layer* property that references the layer + * to be added. When a listener returns "false" the adding will be + * aborted. + * addlayer - triggered after a layer has been added. The event object + * will include a *layer* property that references the added layer. + * preremovelayer - triggered before a layer has been removed. The event + * object will include a *layer* property that references the layer + * to be removed. When a listener returns "false" the removal will be + * aborted. + * removelayer - triggered after a layer has been removed. The event + * object will include a *layer* property that references the removed + * layer. + * changelayer* triggered after a layer name change, order change, + * opacity change, params change, visibility change (due to resolution + * thresholds) or attribution change (due to extent change). Listeners + * will receive an event object with *layer* and *property* properties. + * The *layer* property will be a reference to the changed layer. The + * *property* property will be a key to the changed property (name, + * order, opacity, params, visibility or attribution). + * movestart* triggered after the start of a drag, pan, or zoom + * move - triggered after each drag, pan, or zoom + * moveend - triggered after a drag, pan, or zoom completes + * zoomend - triggered after a zoom completes + * mouseover - triggered after mouseover the map + * mouseout - triggered after mouseout the map + * mousemove - triggered after mousemove the map + * changebaselayer - triggered after the base layer changes */ /** diff --git a/lib/OpenLayers/Strategy/Save.js b/lib/OpenLayers/Strategy/Save.js index c928eebdad..baa4b14777 100644 --- a/lib/OpenLayers/Strategy/Save.js +++ b/lib/OpenLayers/Strategy/Save.js @@ -20,16 +20,20 @@ OpenLayers.Strategy.Save = OpenLayers.Class(OpenLayers.Strategy, { /** + * APIProperty: events + * {} An events object that handles all + * events on the strategy object. + * * Register a listener for a particular event with the following syntax: * (code) * strategy.events.register(type, obj, listener); * (end) * * Supported event types: - * - *start* Triggered before saving - * - *success* Triggered after a successful transaction - * - *fail* Triggered after a failed transaction - * + * start - Triggered before saving + * success - Triggered after a successful transaction + * fail - Triggered after a failed transaction + * */ /** diff --git a/lib/OpenLayers/Tile.js b/lib/OpenLayers/Tile.js index 7251381406..d1d11eef8f 100644 --- a/lib/OpenLayers/Tile.js +++ b/lib/OpenLayers/Tile.js @@ -23,22 +23,25 @@ */ OpenLayers.Tile = OpenLayers.Class({ - /** - * Supported event types: - * - *beforedraw* Triggered before the tile is drawn. Used to defer - * drawing to an animation queue. To defer drawing, listeners need - * to return false, which will abort drawing. The queue handler needs - * to call (true) to actually draw the tile. - * - *loadstart* Triggered when tile loading starts. - * - *loadend* Triggered when tile loading ends. - * - *reload* Triggered when an already loading tile is reloaded. - * - *unload* Triggered before a tile is unloaded. - */ - /** * APIProperty: events * {} An events object that handles all - * events on the tile. + * events on the tile. + * + * Register a listener for a particular event with the following syntax: + * (code) + * tile.events.register(type, obj, listener); + * (end) + * + * Supported event types: + * beforedraw - Triggered before the tile is drawn. Used to defer + * drawing to an animation queue. To defer drawing, listeners need + * to return false, which will abort drawing. The queue handler needs + * to call (true) to actually draw the tile. + * loadstart - Triggered when tile loading starts. + * loadend - Triggered when tile loading ends. + * reload - Triggered when an already loading tile is reloaded. + * unload - Triggered before a tile is unloaded. */ events: null, From 977c334fa3f44beea4bc12a9d32cc789cc19f8b9 Mon Sep 17 00:00:00 2001 From: tschaub Date: Thu, 16 Feb 2012 10:41:05 -0700 Subject: [PATCH 71/91] Doc cleanup. --- lib/OpenLayers/Map.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 393e8129ba..0a8f7bde0a 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -68,14 +68,14 @@ OpenLayers.Map = OpenLayers.Class({ * removelayer - triggered after a layer has been removed. The event * object will include a *layer* property that references the removed * layer. - * changelayer* triggered after a layer name change, order change, + * changelayer - triggered after a layer name change, order change, * opacity change, params change, visibility change (due to resolution * thresholds) or attribution change (due to extent change). Listeners * will receive an event object with *layer* and *property* properties. * The *layer* property will be a reference to the changed layer. The * *property* property will be a key to the changed property (name, * order, opacity, params, visibility or attribution). - * movestart* triggered after the start of a drag, pan, or zoom + * movestart - triggered after the start of a drag, pan, or zoom * move - triggered after each drag, pan, or zoom * moveend - triggered after a drag, pan, or zoom completes * zoomend - triggered after a zoom completes From 03ba4dac88af917501d04b4f7d1aab780e446cb0 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Thu, 16 Feb 2012 21:43:36 +0100 Subject: [PATCH 72/91] Remove superfluous comment closing (*/), thanks @mprins. --- lib/OpenLayers/Layer.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js index d543f66e90..687627e2f7 100644 --- a/lib/OpenLayers/Layer.js +++ b/lib/OpenLayers/Layer.js @@ -102,7 +102,6 @@ OpenLayers.Layer = OpenLayers.Class({ * will receive an object with a *map* property referencing the map and * a *layer* property referencing the layer. */ - */ events: null, /** From 3fefe91580aeab40323979691d62b0b9601c75b8 Mon Sep 17 00:00:00 2001 From: fredj Date: Fri, 17 Feb 2012 09:12:59 +0100 Subject: [PATCH 73/91] Remove tabs --- lib/OpenLayers/Layer/MapGuide.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Layer/MapGuide.js b/lib/OpenLayers/Layer/MapGuide.js index 762df37a5e..680b8472c2 100644 --- a/lib/OpenLayers/Layer/MapGuide.js +++ b/lib/OpenLayers/Layer/MapGuide.js @@ -27,10 +27,10 @@ OpenLayers.Layer.MapGuide = OpenLayers.Class(OpenLayers.Layer.Grid, { /** * APIProperty: useHttpTile * {Boolean} use a tile cache exposed directly via a webserver rather than the - * via mapguide server. This does require extra configuration on the Mapguide Server, - * and will only work when singleTile is false. The url for the layer must be set to the - * webserver path rather than the Mapguide mapagent. - * See http://trac.osgeo.org/mapguide/wiki/CodeSamples/Tiles/ServingTilesViaHttp + * via mapguide server. This does require extra configuration on the Mapguide Server, + * and will only work when singleTile is false. The url for the layer must be set to the + * webserver path rather than the Mapguide mapagent. + * See http://trac.osgeo.org/mapguide/wiki/CodeSamples/Tiles/ServingTilesViaHttp **/ useHttpTile: false, From 79b539c1f9049ded835b1ae8fdc6eef72c5c88cd Mon Sep 17 00:00:00 2001 From: fredj Date: Mon, 20 Feb 2012 13:54:08 +0100 Subject: [PATCH 74/91] Simplify parent call (don't use intermediate array) --- lib/OpenLayers/Layer/Zoomify.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/OpenLayers/Layer/Zoomify.js b/lib/OpenLayers/Layer/Zoomify.js index 82e3838365..65fefac858 100644 --- a/lib/OpenLayers/Layer/Zoomify.js +++ b/lib/OpenLayers/Layer/Zoomify.js @@ -87,12 +87,11 @@ OpenLayers.Layer.Zoomify = OpenLayers.Class(OpenLayers.Layer.Grid, { initialize: function(name, url, size, options) { // initilize the Zoomify pyramid for given size - this.initializeZoomify( size ); + this.initializeZoomify(size); - var newArguments = []; - newArguments.push(name, url, size, {}, options); - - OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); + OpenLayers.Layer.Grid.prototype.initialize.apply(this, [ + name, url, size, {}, options + ]); }, /** From 815cafd9008f5f7d0a26ac59562b9b67fa70f3d8 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Tue, 21 Feb 2012 07:53:43 +0100 Subject: [PATCH 75/91] add an option to OpenLayers.Strategy.BBOX to allow not aborting previous requests --- lib/OpenLayers/Strategy/BBOX.js | 11 +++++++---- tests/Strategy/BBOX.html | 14 +++++++++++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/OpenLayers/Strategy/BBOX.js b/lib/OpenLayers/Strategy/BBOX.js index b6307876fb..2f7ff50631 100644 --- a/lib/OpenLayers/Strategy/BBOX.js +++ b/lib/OpenLayers/Strategy/BBOX.js @@ -124,9 +124,12 @@ OpenLayers.Strategy.BBOX = OpenLayers.Class(OpenLayers.Strategy, { * Callback function called on "moveend" or "refresh" layer events. * * Parameters: - * options - {Object} An object with a property named "force", this - * property references a boolean value indicating if new data - * must be incondtionally read. + * options - {Object} Optional object whose properties will determine + * the behaviour of this Strategy + * + * Valid options include: + * force - {Boolean} if true, new data must be unconditionally read. + * noAbort - {Boolean} if true, do not abort previous requests. */ update: function(options) { var mapBounds = this.getMapBounds(); @@ -218,7 +221,7 @@ OpenLayers.Strategy.BBOX = OpenLayers.Class(OpenLayers.Strategy, { * returned by the layer protocol. */ triggerRead: function(options) { - if (this.response) { + if (this.response && options.noAbort !== true) { this.layer.protocol.abort(this.response); this.layer.events.triggerEvent("loadend"); } diff --git a/tests/Strategy/BBOX.html b/tests/Strategy/BBOX.html index c0ff4ff401..aa66c65321 100644 --- a/tests/Strategy/BBOX.html +++ b/tests/Strategy/BBOX.html @@ -33,7 +33,7 @@ } function test_update(t) { - t.plan(5); + t.plan(7); // Create a dummy layer that can act as the map base layer. // This will be unnecessary if #1921 is addressed (allowing @@ -43,9 +43,10 @@ var strategy = new OpenLayers.Strategy.BBOX({ ratio: 1 // makes for easier comparison to map bounds }); + var log = []; var layer = new OpenLayers.Layer.Vector(null, { isBaseLayer: true, - protocol: new OpenLayers.Protocol(), + protocol: new OpenLayers.Protocol({abort: function(response) { log.push(response); }}), strategies: [strategy] }); @@ -61,7 +62,14 @@ * should be removed when the issue(s) described in #1835 are addressed. */ strategy.update({force: true}); - + strategy.response = {}; + strategy.update({force: true}); + t.eq(log.length, 1, "Response aborted"); + log = []; + strategy.update({force: true}); + strategy.update({force: true, noAbort: true}); + t.eq(log.length, 0, "Response not aborted when noAbort is true"); + // test that the strategy bounds were set t.ok(map.getExtent().equals(strategy.bounds), "[set center] bounds set to map extent"); From 990a33662eeeedb9b98c83e2ac55e7c6a604fa3f Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Tue, 21 Feb 2012 12:09:19 +0100 Subject: [PATCH 76/91] incorporate @ahocevar's review --- lib/OpenLayers/Strategy/BBOX.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/OpenLayers/Strategy/BBOX.js b/lib/OpenLayers/Strategy/BBOX.js index 2f7ff50631..6d59e4c2ab 100644 --- a/lib/OpenLayers/Strategy/BBOX.js +++ b/lib/OpenLayers/Strategy/BBOX.js @@ -221,7 +221,7 @@ OpenLayers.Strategy.BBOX = OpenLayers.Class(OpenLayers.Strategy, { * returned by the layer protocol. */ triggerRead: function(options) { - if (this.response && options.noAbort !== true) { + if (this.response && !(options && options.noAbort === true)) { this.layer.protocol.abort(this.response); this.layer.events.triggerEvent("loadend"); } From 050f72b44378bc2a13aec9033b00c86cec863c99 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Wed, 22 Feb 2012 09:55:45 +0100 Subject: [PATCH 77/91] start on a GeoServer profile for SLD --- lib/OpenLayers.js | 1 + lib/OpenLayers/Format/SLD.js | 9 ++ lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js | 142 ++++++++++++++++++ tests/Format/SLD/v1_0_0_GeoServer.html | 88 +++++++++++ tests/list-tests.html | 1 + 5 files changed, 241 insertions(+) create mode 100644 lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js create mode 100644 tests/Format/SLD/v1_0_0_GeoServer.html diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index 78b35da424..360c7868d1 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -287,6 +287,7 @@ "OpenLayers/Format/SLD.js", "OpenLayers/Format/SLD/v1.js", "OpenLayers/Format/SLD/v1_0_0.js", + "OpenLayers/Format/SLD/v1_0_0_GeoServer.js", "OpenLayers/Format/OWSCommon.js", "OpenLayers/Format/OWSCommon/v1.js", "OpenLayers/Format/OWSCommon/v1_0_0.js", diff --git a/lib/OpenLayers/Format/SLD.js b/lib/OpenLayers/Format/SLD.js index 20e8abf79f..2149b0a516 100644 --- a/lib/OpenLayers/Format/SLD.js +++ b/lib/OpenLayers/Format/SLD.js @@ -23,6 +23,15 @@ */ OpenLayers.Format.SLD = OpenLayers.Class(OpenLayers.Format.XML.VersionedOGC, { + /** + * APIProperty: profile + * {String} If provided, use a custom profile. + * + * Currently supported profiles: + * - GeoServer - parses GeoServer vendor specific capabilities for SLD. + */ + profile: null, + /** * APIProperty: defaultVersion * {String} Version number to assume if none found. Default is "1.0.0". diff --git a/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js b/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js new file mode 100644 index 0000000000..663db29d37 --- /dev/null +++ b/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js @@ -0,0 +1,142 @@ +/* Copyright (c) 2006-2012 by OpenLayers Contributors (see authors.txt for + * full list of contributors). Published under the Clear BSD license. + * See http://svn.openlayers.org/trunk/openlayers/license.txt for the + * full text of the license. */ + +/** + * @requires OpenLayers/Format/SLD/v1_0_0.js + */ + +/** + * Class: OpenLayers.Format.SLD/v1_0_0_GeoServer + * Read SLD version 1.0.0 with GeoServer-specific enhanced options. + * See http://svn.osgeo.org/geotools/trunk/modules/extension/xsd/xsd-sld/src/main/resources/org/geotools/sld/bindings/StyledLayerDescriptor.xsd + * + * Inherits from: + * - + */ +OpenLayers.Format.SLD.v1_0_0_GeoServer = OpenLayers.Class( + OpenLayers.Format.SLD.v1_0_0, { + + /** + * Property: version + * {String} The specific parser version. + */ + version: "1.0.0", + + /** + * Property: profile + * {String} The specific profile + */ + profile: "GeoServer", + + /** + * Constructor: OpenLayers.Format.SLD.v1_0_0_GeoServer + * Create a new parser for GeoServer-enhanced SLD version 1.0.0. + * + * Parameters: + * options - {Object} An optional object whose properties will be set on + * this instance. + */ + + /** + * Property: readers + * Contains public functions, grouped by namespace prefix, that will + * be applied when a namespaced node is found matching the function + * name. The function will be applied in the scope of this parser + * with two arguments: the node being read and a context object passed + * from the parent. + */ + readers: { + "sld": OpenLayers.Util.applyDefaults({ + "Priority": function(node, obj) { + var value = this.readers.ogc._expression.call(this, node); + if (value) { + obj.priority = value; + } + }, + "VendorOption": function(node, obj) { + if (!obj.vendorOptions) { + obj.vendorOptions = []; + } + obj.vendorOptions.push({ + name: node.getAttribute("name"), + value: this.getChildValue(node) + }); + } + }, OpenLayers.Format.SLD.v1_0_0.prototype.readers["sld"]), + "ogc": OpenLayers.Format.SLD.v1_0_0.prototype.readers["ogc"] + }, + + /** + * Property: writers + * As a compliment to the readers property, this structure contains public + * writing functions grouped by namespace alias and named like the + * node names they produce. + */ + writers: { + "sld": OpenLayers.Util.applyDefaults({ + "Priority": function(priority) { + return this.writers.sld._OGCExpression.call( + this, "sld:Priority", priority + ); + }, + "VendorOption": function(option) { + return this.createElementNSPlus("sld:VendorOption", { + attributes: {name: option.name}, + value: option.value + }); + }, + "TextSymbolizer": function(symbolizer) { + var node = OpenLayers.Format.SLD.v1_0_0.prototype.writers["sld"]["TextSymbolizer"].apply(this, arguments); + if (symbolizer.externalGraphic || symbolizer.graphicName) { + this.writeNode("Graphic", symbolizer, node); + } + if ("priority" in symbolizer) { + this.writeNode("Priority", symbolizer.priority, node); + } + var options = symbolizer.vendorOptions; + if (options) { + for (var i=0, ii=options.length; i + + + + + +
    + + diff --git a/tests/list-tests.html b/tests/list-tests.html index 1421c2b6dc..92ebdec19a 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -73,6 +73,7 @@
  • Format/Text.html
  • Format/SLD.html
  • Format/SLD/v1_0_0.html
  • +
  • Format/SLD/v1_0_0_GeoServer.html
  • Format/Filter.html
  • Format/Filter/v1.html
  • Format/Filter/v1_0_0.html
  • From b2f95bd537dca45e52eb0cb6135474eaa01809cc Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Wed, 22 Feb 2012 11:03:48 +0100 Subject: [PATCH 78/91] TextSymbolizer->Fill->CssParameter['fill'] should map to fontColor instead --- lib/OpenLayers/Format/SLD/v1.js | 17 +++++++++++++---- tests/Format/SLD/v1_0_0.html | 4 ++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/OpenLayers/Format/SLD/v1.js b/lib/OpenLayers/Format/SLD/v1.js index be1ce6effd..0780c8d163 100644 --- a/lib/OpenLayers/Format/SLD/v1.js +++ b/lib/OpenLayers/Format/SLD/v1.js @@ -338,6 +338,10 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, { "CssParameter": function(node, symbolizer) { var cssProperty = node.getAttribute("name"); var symProperty = this.cssMap[cssProperty]; + // for labels, fill should map to the fontColor + if (symbolizer.label && cssProperty === 'fill') { + symProperty = "fontColor"; + } if(symProperty) { // Limited support for parsing of OGC expressions var value = this.readers.ogc._expression.call(this, node); @@ -862,10 +866,15 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, { return node; }, "CssParameter": function(obj) { + var name = this.getCssProperty(obj.key); + var value = obj.symbolizer[obj.key]; + if (obj.symbolizer.label && name === 'fill') { + value = obj.symbolizer.fontColor; + } // not handling ogc:expressions for now return this.createElementNSPlus("sld:CssParameter", { - attributes: {name: this.getCssProperty(obj.key)}, - value: obj.symbolizer[obj.key] + attributes: {name: name}, + value: value }); }, "TextSymbolizer": function(symbolizer) { @@ -888,7 +897,7 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, { this.writeNode("Halo", symbolizer, node); } // add in optional Fill - if(symbolizer.fillColor != null || + if(symbolizer.fontColor != null || symbolizer.fillOpacity != null) { this.writeNode("Fill", symbolizer, node); } @@ -1004,7 +1013,7 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, { // GraphicFill here // add in CssParameters - if(symbolizer.fillColor) { + if(symbolizer.fillColor || (symbolizer.label && symbolizer.fontColor)) { this.writeNode( "CssParameter", {symbolizer: symbolizer, key: "fillColor"}, diff --git a/tests/Format/SLD/v1_0_0.html b/tests/Format/SLD/v1_0_0.html index a31ba6a5f3..98f4cd161b 100644 --- a/tests/Format/SLD/v1_0_0.html +++ b/tests/Format/SLD/v1_0_0.html @@ -177,7 +177,7 @@ t.eq(text.label, "A ${FOO} label", "(AAA161) first rule has proper text label"); t.eq(layer.userStyles[0].propertyStyles["label"], true, "label added to propertyStyles"); t.eq(text.fontFamily, "Arial", "(AAA161) first rule has proper font family"); - t.eq(text.fillColor, "#000000", "(AAA161) first rule has proper text fill"); + t.eq(text.fontColor, "#000000", "(AAA161) first rule has proper text fill"); t.eq(text.haloRadius, "3", "(AAA161) first rule has proper halo radius"); t.eq(text.haloColor, "#ffffff", "(AAA161) first rule has proper halo color"); @@ -347,7 +347,7 @@ "label": "This is the ${city} in ${state}.", "fontFamily": "Arial", "fontSize": 10, - "fillColor": "blue", + "fontColor": "blue", "fontWeight": "bold", "fontStyle": "normal", "haloRadius": 2, From 82a8602b45f9b033e6458b029b1b5aa8630c5b6e Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Wed, 22 Feb 2012 11:50:37 +0100 Subject: [PATCH 79/91] use a more clean way to achieve the same --- lib/OpenLayers/Format/SLD/v1.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/OpenLayers/Format/SLD/v1.js b/lib/OpenLayers/Format/SLD/v1.js index 0780c8d163..e23a14d995 100644 --- a/lib/OpenLayers/Format/SLD/v1.js +++ b/lib/OpenLayers/Format/SLD/v1.js @@ -866,15 +866,10 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, { return node; }, "CssParameter": function(obj) { - var name = this.getCssProperty(obj.key); - var value = obj.symbolizer[obj.key]; - if (obj.symbolizer.label && name === 'fill') { - value = obj.symbolizer.fontColor; - } // not handling ogc:expressions for now return this.createElementNSPlus("sld:CssParameter", { - attributes: {name: name}, - value: value + attributes: {name: this.getCssProperty(obj.key)}, + value: obj.symbolizer[obj.key] }); }, "TextSymbolizer": function(symbolizer) { @@ -899,7 +894,9 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, { // add in optional Fill if(symbolizer.fontColor != null || symbolizer.fillOpacity != null) { - this.writeNode("Fill", symbolizer, node); + this.writeNode("Fill", { + fillColor: symbolizer.fontColor + }, node); } return node; }, @@ -1013,7 +1010,7 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, { // GraphicFill here // add in CssParameters - if(symbolizer.fillColor || (symbolizer.label && symbolizer.fontColor)) { + if(symbolizer.fillColor) { this.writeNode( "CssParameter", {symbolizer: symbolizer, key: "fillColor"}, From f0cb98a9bf969007018c0c81820e48e6d967cd26 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Wed, 22 Feb 2012 11:57:42 +0100 Subject: [PATCH 80/91] a bit of restructuring, also making sure that a Graphic in a TextSymbolizer can be read and written (this is a GeoServer extension to produce e.g. highway shields) --- lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js | 65 ++++++++++--------- tests/Format/SLD/v1_0_0_GeoServer.html | 12 ++++ 2 files changed, 45 insertions(+), 32 deletions(-) diff --git a/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js b/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js index 663db29d37..dc77fc5387 100644 --- a/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js +++ b/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js @@ -88,55 +88,56 @@ OpenLayers.Format.SLD.v1_0_0_GeoServer = OpenLayers.Class( }); }, "TextSymbolizer": function(symbolizer) { - var node = OpenLayers.Format.SLD.v1_0_0.prototype.writers["sld"]["TextSymbolizer"].apply(this, arguments); + var writers = OpenLayers.Format.SLD.v1_0_0.prototype.writers; + var node = writers["sld"]["TextSymbolizer"].apply(this, arguments); if (symbolizer.externalGraphic || symbolizer.graphicName) { this.writeNode("Graphic", symbolizer, node); } if ("priority" in symbolizer) { this.writeNode("Priority", symbolizer.priority, node); } - var options = symbolizer.vendorOptions; - if (options) { - for (var i=0, ii=options.length; i #000000 + + + square + + #59BF34 + + + #2D6917 + + + 24 + population From d4e0947f1a299c8a727a70da2ef05b298038ad16 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Wed, 22 Feb 2012 12:18:56 +0100 Subject: [PATCH 81/91] even though the parsing and writing is the same for all VendorOption tags, add a more complete list in the test SLD --- tests/Format/SLD/v1_0_0_GeoServer.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/Format/SLD/v1_0_0_GeoServer.html b/tests/Format/SLD/v1_0_0_GeoServer.html index 94defbfe93..c396ec61ce 100644 --- a/tests/Format/SLD/v1_0_0_GeoServer.html +++ b/tests/Format/SLD/v1_0_0_GeoServer.html @@ -88,7 +88,19 @@ population 60 + true + 300 150 + false + 3 + stretch + yes + 10 + true + 15 + false + 0.3 + mbr From 941f3c0913b44701822bd0271cc70c61f453b9ea Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Wed, 22 Feb 2012 12:23:20 +0100 Subject: [PATCH 82/91] change comment to highlight it's both read and write --- lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js b/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js index dc77fc5387..50275e5d32 100644 --- a/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js +++ b/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js @@ -9,9 +9,10 @@ /** * Class: OpenLayers.Format.SLD/v1_0_0_GeoServer - * Read SLD version 1.0.0 with GeoServer-specific enhanced options. + * Read and write SLD version 1.0.0 with GeoServer-specific enhanced options. * See http://svn.osgeo.org/geotools/trunk/modules/extension/xsd/xsd-sld/src/main/resources/org/geotools/sld/bindings/StyledLayerDescriptor.xsd - * + * for more information. + * * Inherits from: * - */ From d6e28e5ab94fb44a51438ae325813ee89f87fbc3 Mon Sep 17 00:00:00 2001 From: Arjen Kopinga Date: Wed, 22 Feb 2012 15:26:21 +0100 Subject: [PATCH 83/91] Added support for named graphics to Canvas renderer --- lib/OpenLayers/Renderer/Canvas.js | 153 ++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) diff --git a/lib/OpenLayers/Renderer/Canvas.js b/lib/OpenLayers/Renderer/Canvas.js index daf9e19e35..da82e1d7f9 100644 --- a/lib/OpenLayers/Renderer/Canvas.js +++ b/lib/OpenLayers/Renderer/Canvas.js @@ -51,6 +51,12 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, { */ pendingRedraw: false, + /** + * Property: cachedSymbolBounds + * {Object} Internal cache of calculated symbol extents. + */ + cachedSymbolBounds: {}, + /** * Constructor: OpenLayers.Renderer.Canvas * @@ -283,6 +289,151 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, { img.src = style.externalGraphic; }, + /** + * Method: drawNamedSymbol + * Called to draw Well Known Graphic Symbol Name. + * This method is only called by the renderer itself. + * + * Parameters: + * geometry - {} + * style - {Object} + * featureId - {String} + */ + drawNamedSymbol: function(geometry, style, featureId) { + var x, y, cx, cy, i, symbolBounds, scaling, angle; + var unscaledStrokeWidth; + var deg2rad = Math.PI / 180.0; + + var symbol = OpenLayers.Renderer.symbol[style.graphicName]; + + if (!symbol) { + throw new Error(style.graphicName + ' is not a valid symbol name'); + } + + if (!symbol.length || symbol.length < 2) return; + + var pt = this.getLocalXY(geometry); + var p0 = pt[0]; + var p1 = pt[1]; + + if (isNaN(p0) || isNaN(p1)) return; + + // Use rounded line caps + this.canvas.lineCap = "round"; + this.canvas.lineJoin = "round"; + + // Scale and rotate symbols, using precalculated bounds whenever possible. + if (style.graphicName in this.cachedSymbolBounds) { + symbolBounds = this.cachedSymbolBounds[style.graphicName]; + } else { + symbolBounds = new OpenLayers.Bounds(); + for(i = 0; i < symbol.length; i+=2) { + symbolBounds.extend(new OpenLayers.LonLat(symbol[i], symbol[i+1])); + } + this.cachedSymbolBounds[style.graphicName] = symbolBounds; + } + + // Push symbol scaling, translation and rotation onto the transformation stack in reverse order. + // Don't forget to apply all canvas transformations to the hitContext canvas as well(!) + this.canvas.save(); + if (this.hitDetection) this.hitContext.save(); + + // Step 3: place symbol at the desired location + this.canvas.translate(p0,p1); + if (this.hitDetection) this.hitContext.translate(p0,p1); + + // Step 2a. rotate the symbol if necessary + angle = deg2rad * style.rotation; // will be NaN when style.rotation is undefined. + if (!isNaN(angle)) { + this.canvas.rotate(angle); + if (this.hitDetection) this.hitContext.rotate(angle); + } + + // // Step 2: scale symbol such that pointRadius equals half the maximum symbol dimension. + scaling = 2.0 * style.pointRadius / Math.max(symbolBounds.getWidth(), symbolBounds.getHeight()); + this.canvas.scale(scaling,scaling); + if (this.hitDetection) this.hitContext.scale(scaling,scaling); + + // Step 1: center the symbol at the origin + cx = symbolBounds.getCenterLonLat().lon; + cy = symbolBounds.getCenterLonLat().lat; + this.canvas.translate(-cx,-cy); + if (this.hitDetection) this.hitContext.translate(-cx,-cy); + + // Don't forget to scale stroke widths, because they are affected by canvas scale transformations as well(!) + // Alternative: scale symbol coordinates manually, so stroke width scaling is not needed anymore. + unscaledStrokeWidth = style.strokeWidth; + style.strokeWidth = unscaledStrokeWidth / scaling; + + if (style.fill !== false) { + this.setCanvasStyle("fill", style); + this.canvas.beginPath(); + for (i=0; i Date: Wed, 22 Feb 2012 15:39:31 +0100 Subject: [PATCH 84/91] Small fix for hit detection on a canvas layer as an illegal feature id might result at a location where the edge of one feature intersects the interior of another. This is due to antialiasing on the hit context canvas which can't be turned off, unfortunately. --- .gitignore | 2 ++ examples/graphic-name.js | 4 ++-- lib/OpenLayers/Renderer/Canvas.js | 11 +++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 42b60260f3..0f81cf6d15 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ /doc/apidocs/ /examples/example-list.js /examples/example-list.xml +/examples/graphic-name.js +/examples/graphic-name.html diff --git a/examples/graphic-name.js b/examples/graphic-name.js index 654a4c997d..267ae071dc 100644 --- a/examples/graphic-name.js +++ b/examples/graphic-name.js @@ -34,14 +34,14 @@ function init(){ var styles = new OpenLayers.StyleMap({ "default": { graphicName: "${type}", - pointRadius: 10, + pointRadius: 40, strokeColor: "fuchsia", strokeWidth: 2, fillColor: "lime", fillOpacity: 0.6 }, "select": { - pointRadius: 20, + pointRadius: 50, fillOpacity: 1, rotation: 45 } diff --git a/lib/OpenLayers/Renderer/Canvas.js b/lib/OpenLayers/Renderer/Canvas.js index da82e1d7f9..e180ef7288 100644 --- a/lib/OpenLayers/Renderer/Canvas.js +++ b/lib/OpenLayers/Renderer/Canvas.js @@ -786,7 +786,7 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, { * layer. */ getFeatureIdFromEvent: function(evt) { - var feature; + var featureId, feature; if (this.hitDetection) { // this dragging check should go in the feature handler if (!this.map.dragging) { @@ -797,7 +797,14 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, { if (data[3] === 255) { // antialiased var id = data[2] + (256 * (data[1] + (256 * data[0]))); if (id) { - feature = this.features["OpenLayers.Feature.Vector_" + (id - 1 + this.hitOverflow)][0]; + featureId = "OpenLayers.Feature.Vector_" + (id - 1 + this.hitOverflow); + try { + feature = this.features["OpenLayers.Feature.Vector_" + (id - 1 + this.hitOverflow)][0]; + } catch(err) { + // Because of antialiasing on the canvas, when the hit location is at a point where the edge of + // one symbol intersects the interior of another symbol, a wrong hit color (and therefore id) results. + // todo: set Antialiasing = 'off' on the hitContext as soon as browsers allow it. + } } } } From 65aeaec284f66b76073672f066b6932d666eb709 Mon Sep 17 00:00:00 2001 From: Arjen Kopinga Date: Wed, 22 Feb 2012 15:52:01 +0100 Subject: [PATCH 85/91] returned graphic-name.js to its original state --- .gitignore | 2 -- examples/graphic-name.js | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 0f81cf6d15..42b60260f3 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,3 @@ /doc/apidocs/ /examples/example-list.js /examples/example-list.xml -/examples/graphic-name.js -/examples/graphic-name.html diff --git a/examples/graphic-name.js b/examples/graphic-name.js index 267ae071dc..654a4c997d 100644 --- a/examples/graphic-name.js +++ b/examples/graphic-name.js @@ -34,14 +34,14 @@ function init(){ var styles = new OpenLayers.StyleMap({ "default": { graphicName: "${type}", - pointRadius: 40, + pointRadius: 10, strokeColor: "fuchsia", strokeWidth: 2, fillColor: "lime", fillOpacity: 0.6 }, "select": { - pointRadius: 50, + pointRadius: 20, fillOpacity: 1, rotation: 45 } From bb3ae997135d3c3f16c85bd12a5cf1390d4d7995 Mon Sep 17 00:00:00 2001 From: Arjen Kopinga Date: Wed, 22 Feb 2012 15:57:54 +0100 Subject: [PATCH 86/91] forgot to actually used featureId in getFeatureIdFromEvent --- lib/OpenLayers/Renderer/Canvas.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/OpenLayers/Renderer/Canvas.js b/lib/OpenLayers/Renderer/Canvas.js index e180ef7288..eb2b7fcc54 100644 --- a/lib/OpenLayers/Renderer/Canvas.js +++ b/lib/OpenLayers/Renderer/Canvas.js @@ -799,7 +799,7 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, { if (id) { featureId = "OpenLayers.Feature.Vector_" + (id - 1 + this.hitOverflow); try { - feature = this.features["OpenLayers.Feature.Vector_" + (id - 1 + this.hitOverflow)][0]; + feature = this.features[featureId][0]; } catch(err) { // Because of antialiasing on the canvas, when the hit location is at a point where the edge of // one symbol intersects the interior of another symbol, a wrong hit color (and therefore id) results. From 7fb62b69333c0cf748d562d8f42340389d48c564 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Wed, 22 Feb 2012 16:18:41 +0100 Subject: [PATCH 87/91] more complete inheritance of readers and writers --- lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js b/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js index 50275e5d32..49596be1c4 100644 --- a/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js +++ b/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js @@ -48,7 +48,7 @@ OpenLayers.Format.SLD.v1_0_0_GeoServer = OpenLayers.Class( * with two arguments: the node being read and a context object passed * from the parent. */ - readers: { + readers: OpenLayers.Util.applyDefaults({ "sld": OpenLayers.Util.applyDefaults({ "Priority": function(node, obj) { var value = this.readers.ogc._expression.call(this, node); @@ -65,9 +65,8 @@ OpenLayers.Format.SLD.v1_0_0_GeoServer = OpenLayers.Class( value: this.getChildValue(node) }); } - }, OpenLayers.Format.SLD.v1_0_0.prototype.readers["sld"]), - "ogc": OpenLayers.Format.SLD.v1_0_0.prototype.readers["ogc"] - }, + }, OpenLayers.Format.SLD.v1_0_0.prototype.readers["sld"]) + }, OpenLayers.Format.SLD.v1_0_0.prototype.readers), /** * Property: writers @@ -75,7 +74,7 @@ OpenLayers.Format.SLD.v1_0_0_GeoServer = OpenLayers.Class( * writing functions grouped by namespace alias and named like the * node names they produce. */ - writers: { + writers: OpenLayers.Util.applyDefaults({ "sld": OpenLayers.Util.applyDefaults({ "Priority": function(priority) { return this.writers.sld._OGCExpression.call( @@ -114,9 +113,8 @@ OpenLayers.Format.SLD.v1_0_0_GeoServer = OpenLayers.Class( var node = writers["sld"]["PolygonSymbolizer"].apply(this, arguments); return this.addVendorOptions(node, symbolizer); } - }, OpenLayers.Format.SLD.v1_0_0.prototype.writers["sld"]), - "ogc": OpenLayers.Format.SLD.v1_0_0.prototype.writers["ogc"] - }, + }, OpenLayers.Format.SLD.v1_0_0.prototype.writers["sld"]) + }, OpenLayers.Format.SLD.v1_0_0.prototype.writers), /** * Method: addVendorOptions From 69660e3530b9c04b1b96aa7b86d250ff1f06dc72 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Wed, 22 Feb 2012 17:22:30 +0100 Subject: [PATCH 88/91] Minor coding style improvements. --- lib/OpenLayers/Renderer/Canvas.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/OpenLayers/Renderer/Canvas.js b/lib/OpenLayers/Renderer/Canvas.js index eb2b7fcc54..35939afdd2 100644 --- a/lib/OpenLayers/Renderer/Canvas.js +++ b/lib/OpenLayers/Renderer/Canvas.js @@ -336,29 +336,29 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, { // Push symbol scaling, translation and rotation onto the transformation stack in reverse order. // Don't forget to apply all canvas transformations to the hitContext canvas as well(!) this.canvas.save(); - if (this.hitDetection) this.hitContext.save(); + if (this.hitDetection) { this.hitContext.save(); } // Step 3: place symbol at the desired location this.canvas.translate(p0,p1); - if (this.hitDetection) this.hitContext.translate(p0,p1); + if (this.hitDetection) { this.hitContext.translate(p0,p1); } // Step 2a. rotate the symbol if necessary angle = deg2rad * style.rotation; // will be NaN when style.rotation is undefined. if (!isNaN(angle)) { this.canvas.rotate(angle); - if (this.hitDetection) this.hitContext.rotate(angle); + if (this.hitDetection) { this.hitContext.rotate(angle); } } // // Step 2: scale symbol such that pointRadius equals half the maximum symbol dimension. scaling = 2.0 * style.pointRadius / Math.max(symbolBounds.getWidth(), symbolBounds.getHeight()); this.canvas.scale(scaling,scaling); - if (this.hitDetection) this.hitContext.scale(scaling,scaling); + if (this.hitDetection) { this.hitContext.scale(scaling,scaling); } // Step 1: center the symbol at the origin cx = symbolBounds.getCenterLonLat().lon; cy = symbolBounds.getCenterLonLat().lat; this.canvas.translate(-cx,-cy); - if (this.hitDetection) this.hitContext.translate(-cx,-cy); + if (this.hitDetection) { this.hitContext.translate(-cx,-cy); } // Don't forget to scale stroke widths, because they are affected by canvas scale transformations as well(!) // Alternative: scale symbol coordinates manually, so stroke width scaling is not needed anymore. @@ -408,7 +408,7 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, { style.strokeWidth = unscaledStrokeWidth; this.canvas.restore(); - if (this.hitDetection) this.hitContext.restore(); + if (this.hitDetection) { this.hitContext.restore(); } this.setCanvasStyle("reset"); }, From 2e69d681022a86cf7733ff4697ee2a24fbf18266 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Thu, 23 Feb 2012 15:55:40 +0100 Subject: [PATCH 89/91] map fill-opacity in TextSymbolizer to fontOpacity --- lib/OpenLayers/Format/SLD/v1.js | 16 +++++++++++----- tests/Format/SLD/v1_0_0_GeoServer.html | 4 +++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/OpenLayers/Format/SLD/v1.js b/lib/OpenLayers/Format/SLD/v1.js index e23a14d995..a6fe969c4a 100644 --- a/lib/OpenLayers/Format/SLD/v1.js +++ b/lib/OpenLayers/Format/SLD/v1.js @@ -338,9 +338,14 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, { "CssParameter": function(node, symbolizer) { var cssProperty = node.getAttribute("name"); var symProperty = this.cssMap[cssProperty]; - // for labels, fill should map to the fontColor - if (symbolizer.label && cssProperty === 'fill') { - symProperty = "fontColor"; + // for labels, fill should map to fontColor and fill-opacity + // to fontOpacity + if (symbolizer.label) { + if (cssProperty === 'fill') { + symProperty = "fontColor"; + } else if (cssProperty === 'fill-opacity') { + symProperty = "fontOpacity"; + } } if(symProperty) { // Limited support for parsing of OGC expressions @@ -893,9 +898,10 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.Filter.v1_0_0, { } // add in optional Fill if(symbolizer.fontColor != null || - symbolizer.fillOpacity != null) { + symbolizer.fontOpacity != null) { this.writeNode("Fill", { - fillColor: symbolizer.fontColor + fillColor: symbolizer.fontColor, + fillOpacity: symbolizer.fontOpacity }, node); } return node; diff --git a/tests/Format/SLD/v1_0_0_GeoServer.html b/tests/Format/SLD/v1_0_0_GeoServer.html index c396ec61ce..bfe9b3ec4a 100644 --- a/tests/Format/SLD/v1_0_0_GeoServer.html +++ b/tests/Format/SLD/v1_0_0_GeoServer.html @@ -71,12 +71,14 @@ #000000 + 0.5 square - #59BF34 + #59BF34 + 0.8 #2D6917 From 094bedda9a39b6d82657064b5b7f7c2397c84848 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Fri, 24 Feb 2012 16:04:07 +0100 Subject: [PATCH 90/91] If maxResolution is not set, we want the serverResolution. After 2fe882f4d83728814c8ec387b13c0f89e8e74986, no default maxResolution is set. To make the Math.min not return 0, we need a fallback if no maxResolution was configured. --- lib/OpenLayers/Layer/Bing.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Layer/Bing.js b/lib/OpenLayers/Layer/Bing.js index 68ea9efd3a..b03b7e6815 100644 --- a/lib/OpenLayers/Layer/Bing.js +++ b/lib/OpenLayers/Layer/Bing.js @@ -169,7 +169,8 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, { } this.addOptions({ maxResolution: Math.min( - this.serverResolutions[res.zoomMin], this.maxResolution + this.serverResolutions[res.zoomMin], + this.maxResolution || Number.POSITIVE_INFINITY ), numZoomLevels: Math.min( res.zoomMax + 1 - res.zoomMin, this.numZoomLevels From 27e5aaf8f0ff2b7c0d0d908ebaedae0b01e3d035 Mon Sep 17 00:00:00 2001 From: Peter Robins Date: Sat, 25 Feb 2012 17:06:30 +0000 Subject: [PATCH 91/91] Map: check default controls are in build --- lib/OpenLayers/Map.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 0a8f7bde0a..15b3bb03dd 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -577,14 +577,20 @@ OpenLayers.Map = OpenLayers.Class({ } if (this.controls == null) { + this.controls = []; if (OpenLayers.Control != null) { // running full or lite? - this.controls = [ new OpenLayers.Control.Navigation(), - new OpenLayers.Control.PanZoom(), - new OpenLayers.Control.ArgParser(), - new OpenLayers.Control.Attribution() - ]; - } else { - this.controls = []; + if (OpenLayers.Control.Navigation) { + this.controls.push(new OpenLayers.Control.Navigation()) + } + if (OpenLayers.Control.PanZoom) { + this.controls.push(new OpenLayers.Control.PanZoom()) + } + if (OpenLayers.Control.ArgParser) { + this.controls.push(new OpenLayers.Control.ArgParser()) + } + if (OpenLayers.Control.Attribution) { + this.controls.push(new OpenLayers.Control.Attribution()) + } } }