From 2e83863e9095d4422cb1e06bc42b461ac270bd2d Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Fri, 30 Mar 2012 23:04:03 +0200 Subject: [PATCH 01/91] error handling in WFSDescribeFeatureType format --- .../Format/WFSDescribeFeatureType.js | 7 ++++++- tests/Format/WFSDescribeFeatureType.html | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Format/WFSDescribeFeatureType.js b/lib/OpenLayers/Format/WFSDescribeFeatureType.js index 697035a595..ed50f6d696 100644 --- a/lib/OpenLayers/Format/WFSDescribeFeatureType.js +++ b/lib/OpenLayers/Format/WFSDescribeFeatureType.js @@ -5,6 +5,7 @@ /** * @requires OpenLayers/Format/XML.js + * @requires OpenLayers/Format/OGCExceptionReport.js */ /** @@ -188,7 +189,11 @@ OpenLayers.Format.WFSDescribeFeatureType = OpenLayers.Class( } var schema = {}; this.readNode(data, schema); - + if (schema.version === undefined) { + // an exception must have occurred, so parse it + var parser = new OpenLayers.Format.OGCExceptionReport(); + schema.error = parser.read(data); + } return schema; }, diff --git a/tests/Format/WFSDescribeFeatureType.html b/tests/Format/WFSDescribeFeatureType.html index 53faa5d584..820ed3d910 100644 --- a/tests/Format/WFSDescribeFeatureType.html +++ b/tests/Format/WFSDescribeFeatureType.html @@ -374,8 +374,24 @@ // GeoServer example above } + function test_read_exception(t) { + t.plan(1); + var text = + '' + + '' + + ' ' + + ' Could not find type: {http://geonode.org/}_map_4_annotations' + + ' ' + + ''; + var format = new OpenLayers.Format.WFSDescribeFeatureType(); + var obj = format.read(text); + t.ok(!!obj.error, "Error reported correctly"); + } + - \ No newline at end of file + From e773ec32d137bddf99b3b3db8c7ded88cce7e7fa Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Fri, 30 Mar 2012 23:33:10 +0200 Subject: [PATCH 02/91] incorporate @ahocevar's suggestion --- lib/OpenLayers/Format/WFSDescribeFeatureType.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Format/WFSDescribeFeatureType.js b/lib/OpenLayers/Format/WFSDescribeFeatureType.js index ed50f6d696..a946da060c 100644 --- a/lib/OpenLayers/Format/WFSDescribeFeatureType.js +++ b/lib/OpenLayers/Format/WFSDescribeFeatureType.js @@ -188,11 +188,12 @@ OpenLayers.Format.WFSDescribeFeatureType = OpenLayers.Class( data = data.documentElement; } var schema = {}; - this.readNode(data, schema); - if (schema.version === undefined) { + if (data.nodeName.split(":").pop() === 'ExceptionReport') { // an exception must have occurred, so parse it var parser = new OpenLayers.Format.OGCExceptionReport(); schema.error = parser.read(data); + } else { + this.readNode(data, schema); } return schema; }, From da67953c6161f06b853b6b0b368a6b88a586db5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Sat, 3 Mar 2012 17:54:42 +0100 Subject: [PATCH 03/91] add a REST example in wmts-capabilities --- examples/wmts-capabilities.html | 14 ++++++--- examples/wmts-capabilities.js | 52 ++++++++++++++++++++++++++++----- 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/examples/wmts-capabilities.html b/examples/wmts-capabilities.html index 21b3cae0c7..638d335a3c 100644 --- a/examples/wmts-capabilities.html +++ b/examples/wmts-capabilities.html @@ -20,15 +20,21 @@

Web Map Tile Service (WMTS) Capabilities Parsing

wmts, capabilities, getcapabilities -
+

The WMTS Capabilities format allows for parsing of capabilities - documents from OGC Web Map Tile Service (WMTS) version 1.0.0 + documents from OGC Web Map Tile Service (WMTS) version 1.0.0 implementations.

- + +

KVP version.

+
- + +

REST version.

+ +
+

This example creates an OpenLayers.Layer.WMTS layer to based diff --git a/examples/wmts-capabilities.js b/examples/wmts-capabilities.js index dc12941058..d507d1bec0 100644 --- a/examples/wmts-capabilities.js +++ b/examples/wmts-capabilities.js @@ -1,15 +1,20 @@ OpenLayers.ProxyHost = "/proxy/?url="; var map, format; +var map2, format2; function init() { - + + /* + * KVP version + */ + format = new OpenLayers.Format.WMTSCapabilities({ /** * This particular service is not in compliance with the WMTS spec and * is providing coordinates in y, x order regardless of the CRS. To - * work around this, we can provide the format a table of CRS URN that - * should be considered y, x order. These will extend the defaults on + * work around this, we can provide the format a table of CRS URN that + * should be considered y, x order. These will extend the defaults on * the format. */ yx: { @@ -38,22 +43,53 @@ function init() { isBaseLayer: false }); map.addLayer(layer); - }, + }, failure: function() { alert("Trouble getting capabilities doc"); OpenLayers.Console.error.apply(OpenLayers.Console, arguments); } }); - + map = new OpenLayers.Map({ div: "map", projection: "EPSG:900913" - }); - + }); + var osm = new OpenLayers.Layer.OSM(); map.addLayer(osm); map.addControl(new OpenLayers.Control.LayerSwitcher()); map.setCenter(new OpenLayers.LonLat(-13677832, 5213272), 13); - + + + /* + * REST version + */ + format2 = new OpenLayers.Format.WMTSCapabilities(); + + OpenLayers.Request.GET({ + url: "http://wmts.geo.admin.ch/1.0.0/WMTSCapabilities.xml", + success: function(request) { + var doc = request.responseXML; + if (!doc || !doc.documentElement) { + doc = request.responseText; + } + var capabilities = format2.read(doc); + var layer = format2.createLayer(capabilities, { + layer: "ch.are.gemeindetyp-1990-9klassen", + // not avalable in the WMTS Capabilities in native projection + maxExtent: [485869.5728, 76443.1884, 837076.5648, 299941.7864] + }); + map2.addLayer(layer); + map2.setCenter(new OpenLayers.LonLat(540000, 160000), 17); + }, + failure: function() { + alert("Trouble getting capabilities doc"); + OpenLayers.Console.error.apply(OpenLayers.Console, arguments); + } + }); + + map2 = new OpenLayers.Map({ + div: "map2" + }); } From e3a32f29a879f90ac0278b9c2a3f999e5e048262 Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Mon, 21 May 2012 16:40:36 +0200 Subject: [PATCH 04/91] Util methods to detect vendor prefix for DOM properties and CSS --- lib/OpenLayers/Util.js | 82 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index ac598f2604..871288a418 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -1508,6 +1508,88 @@ OpenLayers.Util.getBrowserName = function() { return OpenLayers.BROWSER_NAME; }; +/** + * Constant: VENDOR_DOM_PREFIXES + * {Array} A list of prefixes to test support for vendor-prefixed properties + */ +OpenLayers.Util.VENDOR_DOM_PREFIXES = ["", "O", "ms", "Moz", "Webkit"]; + +/** + * Method: getVendorPrefixedCss + * + * Parameters: + * property - {String} The standard CSS property name + * + * Returns: + * {String} The CSS property name supported by the browser or null if + * unsupported + */ +OpenLayers.Util.getVendorPrefixedCss = (function() { + var cache = {}; + + function domToCss(prefixedDom) { + return prefixedDom. + replace(/([A-Z])/g, function(char) { return "-" + char.toLowerCase(); }). + replace(/^ms-/, "-ms-"); + } + + return function(property) { + // clear cache for tests + if (property === "clear cache") { cache = {}; return; } + + if (cache[property] === undefined) { + var domProperty = property. + replace(/(-.)/g, function(c) { return c.charAt(1).toUpperCase(); }); + var prefixedDom = OpenLayers.Util.getVendorPrefixedDom(domProperty); + cache[property] = domToCss(prefixedDom); + } + return cache[property]; + }; +})(); + +/** + * Method: getVendorPrefixedDom + * + * Parameters: + * property - {String} The standard DOM property name + * + * Returns: + * {String} The DOM property name supported by the browser or null if + * unsupported + */ +OpenLayers.Util.getVendorPrefixedDom = (function() { + var cache = {}; + + return function(property) { + // clear cache for tests + if (property === "clear cache") { cache = {}; return; } + + if (cache[property] === undefined) { + var el = document.createElement("div"), + tmpProp, + i = 0, + l = OpenLayers.Util.VENDOR_DOM_PREFIXES.length, + prefix; + + cache[property] = null; + for(var i=0,l=OpenLayers.Util.VENDOR_DOM_PREFIXES.length; i Date: Mon, 21 May 2012 16:41:55 +0200 Subject: [PATCH 05/91] Tests for vendor prefix detection --- tests/Util.html | 68 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/tests/Util.html b/tests/Util.html index ecb583beb0..84f67b1664 100644 --- a/tests/Util.html +++ b/tests/Util.html @@ -1119,6 +1119,71 @@ t.eq(OpenLayers.Util.getFormattedLonLat(-181, "lon"), "179°00'00\"E", "crossing dateline from the west results in correct east coordinate"); t.eq(OpenLayers.Util.getFormattedLonLat(181, "lon"), "179°00'00\"W", "crossing dateline from the east results in correct west coordinate"); } + + /** + * Test vendor prefixing + */ + function test_vendor_prefixes(t) { + t.plan(12); + var o = {}, err; + var orgCreateElement = document.createElement; + // wrap document.createElement to control property values + document.createElement = function(type) { + var el = orgCreateElement.call(document, type); + // Since o is an object we can change prop for each test + if(o.prop) { + el.style[o.prop] = o.val; + } + return el; + }; + + function curryTestPrefix(type) { + return function(standardProp, expectedPrefix, msg) { + var prefixedProp, err, method = "getVendorPrefixed" + type; + try { + OpenLayers.Util[method]("clear cache"); + prefixedProp = OpenLayers.Util[method](standardProp); + } catch(e) { + err = e; + } + if(!err) { + t.eq(prefixedProp, expectedPrefix, msg); + } else { + t.fail("Error when testing " + type.toUpperCase() + " vendor prefix: " + err.message); + } + }; + } + var testDomPrefix = curryTestPrefix("Dom"), + testCssPrefix = curryTestPrefix("Css"); + + o.prop = "test"; + o.val = ""; + testDomPrefix("test", "test", "DOM vendor prefix - single word"); + testCssPrefix("test", "test", "CSS vendor prefix - single word"); + + o.prop = "testMultiWord"; + testDomPrefix("testMultiWord", "testMultiWord", "DOM vendor prefix - multiple words"); + testCssPrefix("test-multi-word", "test-multi-word", "CSS vendor prefix - multiple words"); + + o.prop = "WebkitMultiWord"; + testDomPrefix("multiWord", "WebkitMultiWord", "DOM vendor prefix - multiple words for WebKit"); + testCssPrefix("multi-word", "-webkit-multi-word", "CSS vendor prefix - multiple words for WebKit"); + + o.prop = "MozMultiWord"; + testDomPrefix("multiWord", "MozMultiWord", "DOM vendor prefix - multiple words for Mozilla"); + testCssPrefix("multi-word", "-moz-multi-word", "CSS vendor prefix - multiple words for Mozilla"); + + o.prop = "OMultiWord"; + testDomPrefix("multiWord", "OMultiWord", "DOM vendor prefix - multiple words for Opera"); + testCssPrefix("multi-word", "-o-multi-word", "CSS vendor prefix - multiple words for Opera"); + + o.prop = "msMultiWord"; + testDomPrefix("multiWord", "msMultiWord", "DOM vendor prefix - multiple words for Internet Explorer"); + testCssPrefix("multi-word", "-ms-multi-word", "CSS vendor prefix - multiple words for Internet Explorer"); + + // unwrap document.createElement + document.createElement = orgCreateElement; + } /** * To test that we can safely call OpenLayers.Util.extend with an Event @@ -1127,7 +1192,7 @@ var loadEvent; window.onload = function(evt) { loadEvent = evt || window.event; - } + }; function test_extend_event(t) { t.plan(2); t.ok(loadEvent, "loadEvent recorded"); @@ -1143,6 +1208,7 @@ t.eq(extended && extended.foo, "bar", "extended with event"); } } + From 875a2b98fff0ae4feee791e5a571cbf96d0d1558 Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Tue, 22 May 2012 17:05:13 +0200 Subject: [PATCH 06/91] API description should inform that the method only tests for DOM style properties. Not object properties. --- lib/OpenLayers/Util.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index 871288a418..6ae9a2987b 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -1551,10 +1551,10 @@ OpenLayers.Util.getVendorPrefixedCss = (function() { * Method: getVendorPrefixedDom * * Parameters: - * property - {String} The standard DOM property name + * property - {String} The standard DOM style property name * * Returns: - * {String} The DOM property name supported by the browser or null if + * {String} The DOM style property name supported by the browser or null if * unsupported */ OpenLayers.Util.getVendorPrefixedDom = (function() { From a18ce5adf65efed0e440aaa0d3ebb6e41e7fdf25 Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Tue, 22 May 2012 17:06:03 +0200 Subject: [PATCH 07/91] Rewrite PinchZoom to detect vendor-prefix, so it works in more browsers --- lib/OpenLayers/Control/PinchZoom.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Control/PinchZoom.js b/lib/OpenLayers/Control/PinchZoom.js index 89240190a9..bd502f3d7d 100644 --- a/lib/OpenLayers/Control/PinchZoom.js +++ b/lib/OpenLayers/Control/PinchZoom.js @@ -162,8 +162,10 @@ OpenLayers.Control.PinchZoom = OpenLayers.Class(OpenLayers.Control, { */ applyTransform: function(transform) { var style = this.map.layerContainerDiv.style; - style['-webkit-transform'] = transform; - style['-moz-transform'] = transform; + var transformProperty = OpenLayers.Util.getVendorPrefixedDom("transform"); + if (transformProperty) { + style[transformProperty] = transform; + } }, /** From cf92ced1c89c558345fb30394403158dd5982dde Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Tue, 6 Mar 2012 11:49:42 +0100 Subject: [PATCH 08/91] Add tests/manual/map-events.html test file --- tests/manual/map-events.html | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/manual/map-events.html diff --git a/tests/manual/map-events.html b/tests/manual/map-events.html new file mode 100644 index 0000000000..3695e82da4 --- /dev/null +++ b/tests/manual/map-events.html @@ -0,0 +1,38 @@ + + + + + + + map.div Events Acceptance Test + + + + + + +

map.div Events Acceptance Test

+ +
+ +

Test 1 : mousedown the map; an alert must be displayed.

+ + From a6119f6a7528e013b922fd0d997a07df13f6bd6e Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 14 Mar 2012 10:30:03 +0100 Subject: [PATCH 09/91] Prevent the default browser behavior without stopping the event propagation. --- lib/OpenLayers/Events.js | 22 +++++++++++++++++----- lib/OpenLayers/Handler/Drag.js | 3 ++- lib/OpenLayers/Handler/Pinch.js | 2 +- tests/Handler/Drag.html | 24 +++++++++--------------- 4 files changed, 29 insertions(+), 22 deletions(-) diff --git a/lib/OpenLayers/Events.js b/lib/OpenLayers/Events.js index c2b5b99d46..1cf1b64996 100644 --- a/lib/OpenLayers/Events.js +++ b/lib/OpenLayers/Events.js @@ -167,11 +167,7 @@ OpenLayers.Event = { stop: function(event, allowDefault) { if (!allowDefault) { - if (event.preventDefault) { - event.preventDefault(); - } else { - event.returnValue = false; - } + OpenLayers.Event.preventDefault(event); } if (event.stopPropagation) { @@ -181,6 +177,22 @@ OpenLayers.Event = { } }, + /** + * Method: preventDefault + * Cancels the event if it is cancelable, without stopping further + * propagation of the event. + * + * Parameters: + * event - {Event} + */ + preventDefault: function(event) { + if (event.preventDefault) { + event.preventDefault(); + } else { + event.returnValue = false; + } + }, + /** * Method: findElement * diff --git a/lib/OpenLayers/Handler/Drag.js b/lib/OpenLayers/Handler/Drag.js index 59456a8fe2..a0aab81bf9 100644 --- a/lib/OpenLayers/Handler/Drag.js +++ b/lib/OpenLayers/Handler/Drag.js @@ -172,7 +172,8 @@ OpenLayers.Handler.Drag = OpenLayers.Class(OpenLayers.Handler, { this.down(evt); this.callback("down", [evt.xy]); - OpenLayers.Event.stop(evt); + // prevent document dragging + OpenLayers.Event.preventDefault(evt); if(!this.oldOnselectstart) { this.oldOnselectstart = document.onselectstart ? diff --git a/lib/OpenLayers/Handler/Pinch.js b/lib/OpenLayers/Handler/Pinch.js index 1d115a2c5a..24138cf6dd 100644 --- a/lib/OpenLayers/Handler/Pinch.js +++ b/lib/OpenLayers/Handler/Pinch.js @@ -103,7 +103,7 @@ OpenLayers.Handler.Pinch = OpenLayers.Class(OpenLayers.Handler, { this.last = null; } // prevent document dragging - OpenLayers.Event.stop(evt); + OpenLayers.Event.preventDefault(evt); return propagate; }, diff --git a/tests/Handler/Drag.html b/tests/Handler/Drag.html index 4be1df9e6d..71ad3ef71f 100644 --- a/tests/Handler/Drag.html +++ b/tests/Handler/Drag.html @@ -117,7 +117,7 @@ handler.activate(); var oldIsLeftClick = OpenLayers.Event.isLeftClick; - var oldStop = OpenLayers.Event.stop; + var oldPreventDefault = OpenLayers.Event.preventDefault; var oldCheckModifiers = handler.checkModifiers; // test mousedown with right click @@ -163,15 +163,9 @@ "mousedown calls isLeftClick with the proper event"); return true; } - OpenLayers.Event.stop = function(evt, allowDefault) { - if(!allowDefault) { - t.ok(evt.xy.x == testEvents.down.xy.x && - evt.xy.y == testEvents.down.xy.y, - "mousedown default action is disabled"); - } else { - t.fail( - "mousedown is prevented from falling to other elements"); - } + OpenLayers.Event.preventDefault = function(evt) { + t.ok(evt.xy.x == testEvents.down.xy.x && evt.xy.y == testEvents.down.xy.y, + "mousedown default action is disabled"); } map.events.triggerEvent("mousedown", testEvents.down); t.ok(handler.started, "mousedown sets the started flag to true"); @@ -183,7 +177,7 @@ handler.last.y == testEvents.down.xy.y, "mouse down sets handler.last correctly"); - OpenLayers.Event.stop = oldStop; + OpenLayers.Event.preventDefault = oldPreventDefault; OpenLayers.Event.isLeftClick = oldIsLeftClick; handler.checkModifiers = oldCheckModifiers; @@ -292,7 +286,7 @@ function test_Handler_Drag_touch(t) { // In this test we verify that "touchstart", "touchmove", and // "touchend" events set expected states in the drag handler. - // We also verify that we stop event bubbling as appropriate. + // We also verify that we prevent the default as appropriate. t.plan(14); @@ -308,8 +302,8 @@ }); h.activate(); - var _stop = OpenLayers.Event.stop; - OpenLayers.Event.stop = function(e) { + var _preventDefault = OpenLayers.Event.preventDefault; + OpenLayers.Event.preventDefault = function(e) { log.push(e); }; @@ -343,7 +337,7 @@ // tear down - OpenLayers.Event.stop = _stop; + OpenLayers.Event.preventDefault = _preventDefault; m.destroy(); } From 74dd106082d982cb5d16fdf5f16b00deb91dbb91 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Tue, 29 May 2012 09:14:33 +0200 Subject: [PATCH 10/91] Use OpenLayers.Event.preventDefault, deprecate OpenLayers.Renderer.SVG.preventDefault. --- lib/OpenLayers/Renderer/SVG.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Renderer/SVG.js b/lib/OpenLayers/Renderer/SVG.js index 85be57989e..29adaa5cb9 100644 --- a/lib/OpenLayers/Renderer/SVG.js +++ b/lib/OpenLayers/Renderer/SVG.js @@ -284,7 +284,7 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, { node.setAttributeNS(null, "height", height); node.setAttributeNS(this.xlinkns, "href", style.externalGraphic); node.setAttributeNS(null, "style", "opacity: "+opacity); - node.onclick = OpenLayers.Renderer.SVG.preventDefault; + node.onclick = OpenLayers.Event.preventDefault; } else if (this.isComplexSymbol(style.graphicName)) { // the symbol viewBox is three times as large as the symbol var offset = style.pointRadius * 3; @@ -1000,9 +1000,10 @@ OpenLayers.Renderer.SVG.LABEL_VFACTOR = { /** * Function: OpenLayers.Renderer.SVG.preventDefault + * *Deprecated*. Use method instead. * Used to prevent default events (especially opening images in a new tab on * ctrl-click) from being executed for externalGraphic symbols */ OpenLayers.Renderer.SVG.preventDefault = function(e) { - e.preventDefault && e.preventDefault(); + OpenLayers.Event.preventDefault(e); }; From 54a51904e956696016c8604c3bc2be8ef45be306 Mon Sep 17 00:00:00 2001 From: Xavier Mamano Date: Sun, 3 Jun 2012 16:54:20 +0200 Subject: [PATCH 11/91] Adjustment on "Util.getRenderedDimensions" when "containerElement" is absolutely positioned. --- lib/OpenLayers/Util.js | 57 +++++++++++++++++---------- tests/manual/rendered-dimensions.html | 54 +++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 20 deletions(-) diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index 491448c9c9..8e326a3b30 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -1526,6 +1526,33 @@ OpenLayers.Util.getRenderedDimensions = function(contentHTML, size, options) { var containerElement = (options && options.containerElement) ? options.containerElement : document.body; + + // Opera and IE7 can't handle a node with position:aboslute if it inherits + // position:absolute from a parent. + var parentHasPositionAbsolute = false; + var superContainer = null; + var parent = containerElement; + while (parent && parent.tagName.toLowerCase()!="body") { + var parentPosition = OpenLayers.Element.getStyle(parent, "position"); + if(parentPosition == "absolute") { + parentHasPositionAbsolute = true; + break; + } else if (parentPosition && parentPosition != "static") { + break; + } + parent = parent.parentNode; + } + if(parentHasPositionAbsolute && (containerElement.clientHeight === 0 || + containerElement.clientWidth === 0) ){ + superContainer = document.createElement("div"); + superContainer.style.visibility = "hidden"; + superContainer.style.position = "absolute"; + superContainer.style.overflow = "visible"; + superContainer.style.width = document.body.clientWidth + "px"; + superContainer.style.height = document.body.clientHeight + "px"; + superContainer.appendChild(container); + } + container.style.position = "absolute"; //fix a dimension, if specified. if (size) { @@ -1560,25 +1587,10 @@ OpenLayers.Util.getRenderedDimensions = function(contentHTML, size, options) { container.appendChild(content); // append container to body for rendering - containerElement.appendChild(container); - - // Opera and IE7 can't handle a node with position:aboslute if it inherits - // position:absolute from a parent. - var parentHasPositionAbsolute = false; - var parent = container.parentNode; - while (parent && parent.tagName.toLowerCase()!="body") { - var parentPosition = OpenLayers.Element.getStyle(parent, "position"); - if(parentPosition == "absolute") { - parentHasPositionAbsolute = true; - break; - } else if (parentPosition && parentPosition != "static") { - break; - } - parent = parent.parentNode; - } - - if(!parentHasPositionAbsolute) { - container.style.position = "absolute"; + if (superContainer) { + containerElement.appendChild(superContainer); + } else { + containerElement.appendChild(container); } // calculate scroll width of content and add corners and shadow width @@ -1595,7 +1607,12 @@ OpenLayers.Util.getRenderedDimensions = function(contentHTML, size, options) { // remove elements container.removeChild(content); - containerElement.removeChild(container); + if (superContainer) { + superContainer.removeChild(container); + containerElement.removeChild(superContainer); + } else { + containerElement.removeChild(container); + } return new OpenLayers.Size(w, h); }; diff --git a/tests/manual/rendered-dimensions.html b/tests/manual/rendered-dimensions.html index 41b0fcf4d4..72f0eecc1d 100644 --- a/tests/manual/rendered-dimensions.html +++ b/tests/manual/rendered-dimensions.html @@ -39,10 +39,64 @@ function run() { else { out.innerHTML += "
height Fail: " + size + ", " + height; } + + // To use the same syntax as in "\tests" + t = {eq: function(a, b, msg) { + if (a == b) { + out.innerHTML += "
ok " + msg; + } + else { + out.innerHTML += "
Fail (" + a + " not eq " + b + "): " + msg + ""; + } + } + } + var text = (new Array(10)).join("foo foo foo
"), + content = "
" + text + "
"; + var testName, + finalSize, + initialSize = OpenLayers.Util.getRenderedDimensions(content, null); + // containerElement option on absolute position with width and height + testName = "Absolute with w&h: "; + var optionAbsDiv ={ + containerElement: document.getElementById("absoluteDiv") + } + finalSize = OpenLayers.Util.getRenderedDimensions(content, null, optionAbsDiv); + t.eq(finalSize.w, initialSize.w, + testName + "initial width " + initialSize.w + "px is maintained"); + t.eq(finalSize.h, initialSize.h, + testName + "initial height " + initialSize.h + "px is maintained"); + testName = "Absolute with w&h (set height): "; + finalSize = OpenLayers.Util.getRenderedDimensions(content, {h: 15}, optionAbsDiv); + t.eq(finalSize.h, 15, testName + "got the fixed height to 15px"); + t.eq(finalSize.w, initialSize.w, + testName + "initial width " + initialSize.w + "px is maintained"); + testName = "Absolute with w&h (set width): "; + finalSize = OpenLayers.Util.getRenderedDimensions(content, {w: 20}, optionAbsDiv); + t.eq(finalSize.w, 20, testName + "got the fixed width to 20px"); + // containerElement option on absolute position without width and height + testName = "Absolute without w&h: "; + var optionAbsDiv00 ={ + containerElement: document.getElementById("absoluteDiv00") + } + finalSize = OpenLayers.Util.getRenderedDimensions(content, null, optionAbsDiv00); + t.eq(finalSize.w, initialSize.w, + testName + "initial width " + initialSize.w + "px is maintained"); + t.eq(finalSize.h, initialSize.h, + testName + "initial height " + initialSize.h + "px is maintained"); + testName = "Absolute without w&h (set height): "; + finalSize = OpenLayers.Util.getRenderedDimensions(content, {h: 15}, optionAbsDiv00); + t.eq(finalSize.h, 15, testName + "got the fixed height to 15px"); + t.eq(finalSize.w, initialSize.w, + testName + "initial width " + initialSize.w + "px is maintained"); + testName = "Absolute without w&h (set width): "; + finalSize = OpenLayers.Util.getRenderedDimensions(content, {w: 20}, optionAbsDiv00); + t.eq(finalSize.w, 20, testName + "got the fixed width to 20px"); }
+
+
From b7e2222d463fea1c1b237479974ab1c7409065a8 Mon Sep 17 00:00:00 2001 From: Xavier Mamano Date: Sun, 3 Jun 2012 22:45:28 +0200 Subject: [PATCH 12/91] missing semicolons on tests --- tests/manual/rendered-dimensions.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/manual/rendered-dimensions.html b/tests/manual/rendered-dimensions.html index 72f0eecc1d..36ab370905 100644 --- a/tests/manual/rendered-dimensions.html +++ b/tests/manual/rendered-dimensions.html @@ -49,7 +49,7 @@ function run() { out.innerHTML += "
Fail (" + a + " not eq " + b + "): " + msg + ""; } } - } + }; var text = (new Array(10)).join("foo foo foo
"), content = "
" + text + "
"; var testName, @@ -59,7 +59,7 @@ function run() { testName = "Absolute with w&h: "; var optionAbsDiv ={ containerElement: document.getElementById("absoluteDiv") - } + }; finalSize = OpenLayers.Util.getRenderedDimensions(content, null, optionAbsDiv); t.eq(finalSize.w, initialSize.w, testName + "initial width " + initialSize.w + "px is maintained"); @@ -77,7 +77,7 @@ function run() { testName = "Absolute without w&h: "; var optionAbsDiv00 ={ containerElement: document.getElementById("absoluteDiv00") - } + }; finalSize = OpenLayers.Util.getRenderedDimensions(content, null, optionAbsDiv00); t.eq(finalSize.w, initialSize.w, testName + "initial width " + initialSize.w + "px is maintained"); From 2b9ea5007b8fcc209421ffdfd5bc1564e2bdec47 Mon Sep 17 00:00:00 2001 From: Xavier Mamano Date: Sun, 3 Jun 2012 23:54:11 +0200 Subject: [PATCH 13/91] Use "superContainer" to operate well in Android, . --- lib/OpenLayers/Util.js | 3 +-- tests/manual/rendered-dimensions.html | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index 8e326a3b30..e88ce435e2 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -1542,8 +1542,7 @@ OpenLayers.Util.getRenderedDimensions = function(contentHTML, size, options) { } parent = parent.parentNode; } - if(parentHasPositionAbsolute && (containerElement.clientHeight === 0 || - containerElement.clientWidth === 0) ){ + if(parentHasPositionAbsolute){ superContainer = document.createElement("div"); superContainer.style.visibility = "hidden"; superContainer.style.position = "absolute"; diff --git a/tests/manual/rendered-dimensions.html b/tests/manual/rendered-dimensions.html index 36ab370905..71025afef8 100644 --- a/tests/manual/rendered-dimensions.html +++ b/tests/manual/rendered-dimensions.html @@ -41,7 +41,7 @@ function run() { } // To use the same syntax as in "\tests" - t = {eq: function(a, b, msg) { + var t = {eq: function(a, b, msg) { if (a == b) { out.innerHTML += "
ok " + msg; } From 4f3252bfe851082bb2547643a1ea32d3c51b15a2 Mon Sep 17 00:00:00 2001 From: Xavier Mamano Date: Mon, 4 Jun 2012 18:49:43 +0200 Subject: [PATCH 14/91] Revert "Use "superContainer" to operate well in Android, ." This reverts commit 2b9ea5007b8fcc209421ffdfd5bc1564e2bdec47. --- lib/OpenLayers/Util.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index e88ce435e2..8e326a3b30 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -1542,7 +1542,8 @@ OpenLayers.Util.getRenderedDimensions = function(contentHTML, size, options) { } parent = parent.parentNode; } - if(parentHasPositionAbsolute){ + if(parentHasPositionAbsolute && (containerElement.clientHeight === 0 || + containerElement.clientWidth === 0) ){ superContainer = document.createElement("div"); superContainer.style.visibility = "hidden"; superContainer.style.position = "absolute"; From acb489ad79e0e100a69c77b97579bee469526299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Mon, 4 Jun 2012 22:02:36 +0200 Subject: [PATCH 15/91] set VERSION_NUMBER to 2.12-rc6 --- lib/OpenLayers.js | 2 +- lib/OpenLayers/SingleFile.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index d00fc976cb..e2922161e7 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -414,4 +414,4 @@ /** * Constant: VERSION_NUMBER */ -OpenLayers.VERSION_NUMBER="Release 2.12-rc5"; +OpenLayers.VERSION_NUMBER="Release 2.12-rc6"; diff --git a/lib/OpenLayers/SingleFile.js b/lib/OpenLayers/SingleFile.js index 53fa0ceb8d..797fc34394 100644 --- a/lib/OpenLayers/SingleFile.js +++ b/lib/OpenLayers/SingleFile.js @@ -7,7 +7,7 @@ var OpenLayers = { /** * Constant: VERSION_NUMBER */ - VERSION_NUMBER: "Release 2.12-rc5", + VERSION_NUMBER: "Release 2.12-rc6", /** * Constant: singleFile From cbba98279b86e1a05a122f4ab1aeb6d5cc670cea Mon Sep 17 00:00:00 2001 From: Andrew Vardeman Date: Mon, 4 Jun 2012 15:47:43 -0500 Subject: [PATCH 16/91] unsubscribe from events on the proper layer --- lib/OpenLayers/Control/Split.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/OpenLayers/Control/Split.js b/lib/OpenLayers/Control/Split.js index c382eae3a9..3cc790d182 100644 --- a/lib/OpenLayers/Control/Split.js +++ b/lib/OpenLayers/Control/Split.js @@ -240,7 +240,7 @@ OpenLayers.Control.Split = OpenLayers.Class(OpenLayers.Control, { var deactivated = OpenLayers.Control.prototype.deactivate.call(this); if(deactivated) { if(this.source && this.source.events) { - this.layer.events.un({ + this.source.events.un({ sketchcomplete: this.onSketchComplete, afterfeaturemodified: this.afterFeatureModified, scope: this From f64912c09d08d3aae3ce319e3c17ff4e35cfe7c4 Mon Sep 17 00:00:00 2001 From: Andrew Vardeman Date: Mon, 4 Jun 2012 17:25:54 -0500 Subject: [PATCH 17/91] use two different layers for Split tool's layer and the source layer so as to properly check for event unregistration --- tests/Control/Split.html | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tests/Control/Split.html b/tests/Control/Split.html index 86af76c56d..e3a6eacecf 100644 --- a/tests/Control/Split.html +++ b/tests/Control/Split.html @@ -104,13 +104,18 @@ t.plan(7); - var layer = new OpenLayers.Layer.Vector("foo", { + var layer1 = new OpenLayers.Layer.Vector("foo", { maxExtent: new OpenLayers.Bounds(-10, -10, 10, 10), isBaseLayer: true }); - var control = new OpenLayers.Control.Split({layer: layer}); + var layer2 = new OpenLayers.Layer.Vector("bar", { + maxExtent: new OpenLayers.Bounds(-10, -10, 10, 10), + isBaseLayer: false + }); + var control = new OpenLayers.Control.Split({layer: layer1}); var map = new OpenLayers.Map("map"); - map.addLayer(layer); + map.addLayer(layer1); + map.addLayer(layer2); map.zoomToMaxExtent(); map.addControl(control); @@ -124,17 +129,17 @@ t.eq(control.handler.active, false, "sketch handler deactivated"); // set a source layer - control.setSource(layer); + control.setSource(layer2); // activate and check that listeners are registered control.activate(); - t.ok(layer.events.listeners.sketchcomplete, "sketchcomplete listener registered"); - t.ok(layer.events.listeners.afterfeaturemodified, "afterfeaturemodified listener registered"); + t.ok(layer2.events.listeners.sketchcomplete, "sketchcomplete listener registered"); + t.ok(layer2.events.listeners.afterfeaturemodified, "afterfeaturemodified listener registered"); // deactivate and confirm no draw related events control.deactivate(); - t.eq(layer.events.listeners.sketchcomplete.length, 0, "no sketchcomplete listeners"); - t.eq(layer.events.listeners.afterfeaturemodified.length, 0, "no afterfeaturemodified listeners"); + t.eq(layer2.events.listeners.sketchcomplete.length, 0, "no sketchcomplete listeners"); + t.eq(layer2.events.listeners.afterfeaturemodified.length, 0, "no afterfeaturemodified listeners"); map.destroy(); } From 788d5a645ac6198380144683ad8fb98f610fb7b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Thu, 7 Jun 2012 09:21:44 +0200 Subject: [PATCH 18/91] move the style.mobile.css file from examples to theme/default --- examples/mobile-drawing.html | 2 +- examples/mobile-jq.html | 2 +- examples/mobile-layers.html | 2 +- examples/mobile-navigation.html | 2 +- examples/mobile-sencha.html | 2 +- examples/mobile.html | 2 +- notes/2.12.md | 10 ++++++++++ {examples => theme/default}/style.mobile.css | 0 8 files changed, 16 insertions(+), 6 deletions(-) rename {examples => theme/default}/style.mobile.css (100%) diff --git a/examples/mobile-drawing.html b/examples/mobile-drawing.html index 6a91152b89..0cb9c529f1 100644 --- a/examples/mobile-drawing.html +++ b/examples/mobile-drawing.html @@ -5,7 +5,7 @@ - + diff --git a/examples/mobile-jq.html b/examples/mobile-jq.html index 470fd39d5d..5e16caaa68 100644 --- a/examples/mobile-jq.html +++ b/examples/mobile-jq.html @@ -8,7 +8,7 @@ - + diff --git a/examples/mobile-layers.html b/examples/mobile-layers.html index dcb27645f9..d25867477a 100644 --- a/examples/mobile-layers.html +++ b/examples/mobile-layers.html @@ -5,7 +5,7 @@ - + + image/png + + Time + 20090101 + 20090101 + + + 21781 + + + + + 21781 + urn:ogc:def:crs:EPSG:21781 + + 0 + 14285750.5715 + 420000.0 350000.0 + 256 + 256 + 1 + 1 + + + 8 + 7142875.28575 + 420000.0 350000.0 + 256 + 256 + 1 + 1 + + + 12 + 3571437.64288 + 420000.0 350000.0 + 256 + 256 + 2 + 2 + + + + + +-->
From 96359fbc99730ca1660cf35b90f83a7a4ced3df9 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Mon, 11 Jun 2012 13:38:42 +0200 Subject: [PATCH 23/91] Fixing test that broke in FF with ff1f99a03f766258780139f988ef9e4e18c1d37b. --- tests/Layer/Grid.html | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/Layer/Grid.html b/tests/Layer/Grid.html index 981ccb4e83..50464f3cd8 100644 --- a/tests/Layer/Grid.html +++ b/tests/Layer/Grid.html @@ -1362,7 +1362,7 @@ t.plan(5); // set up - + var map = new OpenLayers.Map('map', { resolutions: [32, 16, 8, 4, 2, 1] }); @@ -1375,28 +1375,28 @@ map.zoomTo(1); - t.delay_call(1, function() { + // Mark one tile loaded, to see if back buffer removal gets scheduled. + layer.grid[1][1].onImageLoad(); - t.ok(layer.backBuffer.parentNode === layer.div, - '[a] back buffer is a child of layer div'); - t.ok(layer.backBufferTimerId !== null, - '[a] back buffer scheduled for removal'); + t.ok(layer.backBuffer.parentNode === layer.div, + '[a] back buffer is a child of layer div'); + t.ok(layer.backBufferTimerId !== null, + '[a] back buffer scheduled for removal'); - var backBuffer = layer.backBuffer; + var backBuffer = layer.backBuffer; - map.zoomTo(2); + map.zoomTo(2); - t.ok(layer.backBuffer !== backBuffer, - '[b] a new back buffer was created'); - t.ok(layer.backBuffer.parentNode === layer.div, - '[b] back buffer is a child of layer div'); - t.ok(layer.backBufferTimerId === null, - '[b] back buffer no longer scheduled for removal'); + t.ok(layer.backBuffer !== backBuffer, + '[b] a new back buffer was created'); + t.ok(layer.backBuffer.parentNode === layer.div, + '[b] back buffer is a child of layer div'); + t.ok(layer.backBufferTimerId === null, + '[b] back buffer no longer scheduled for removal'); - // tear down + // tear down - map.destroy(); - }); + map.destroy(); } function test_getGridData(t) { From 958544f2a72208d8ca36b4410ab20a3363edf9b4 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Mon, 11 Jun 2012 19:07:17 +0200 Subject: [PATCH 24/91] New zoomOnClick option for ZoomBox control. This change also finally adds tests for the ZoomBox control. --- lib/OpenLayers/Control/ZoomBox.js | 12 ++++++-- tests/Control/ZoomBox.html | 51 +++++++++++++++++++++++++++++++ tests/list-tests.html | 1 + 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 tests/Control/ZoomBox.html diff --git a/lib/OpenLayers/Control/ZoomBox.js b/lib/OpenLayers/Control/ZoomBox.js index 8f407adb25..58da952c9d 100644 --- a/lib/OpenLayers/Control/ZoomBox.js +++ b/lib/OpenLayers/Control/ZoomBox.js @@ -41,9 +41,17 @@ OpenLayers.Control.ZoomBox = OpenLayers.Class(OpenLayers.Control, { /** * APIProperty: alwaysZoom - * {Boolean} Always zoom in/out, when box drawed + * {Boolean} Always zoom in/out when box drawn, even if the zoom level does + * not change. */ alwaysZoom: false, + + /** + * APIProperty: zoomOnClick + * {Boolean} Should we zoom when no box was dragged, i.e. the user only + * clicked? Default is true. + */ + zoomOnClick: true, /** * Method: draw @@ -93,7 +101,7 @@ OpenLayers.Control.ZoomBox = OpenLayers.Class(OpenLayers.Control, { if (lastZoom == this.map.getZoom() && this.alwaysZoom == true){ this.map.zoomTo(lastZoom + (this.out ? -1 : 1)); } - } else { // it's a pixel + } else if (this.zoomOnClick) { // it's a pixel if (!this.out) { this.map.setCenter(this.map.getLonLatFromPixel(position), this.map.getZoom() + 1); diff --git a/tests/Control/ZoomBox.html b/tests/Control/ZoomBox.html new file mode 100644 index 0000000000..9ee3fde886 --- /dev/null +++ b/tests/Control/ZoomBox.html @@ -0,0 +1,51 @@ + + + + + + + +
+
in
out + + diff --git a/tests/list-tests.html b/tests/list-tests.html index 14ccf78ed0..c883ed34d7 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -49,6 +49,7 @@
  • Control/PanPanel.html
  • Control/SLDSelect.html
  • Control/Zoom.html
  • +
  • Control/ZoomBox.html
  • Events.html
  • Events/buttonclick.html
  • Extras.html
  • From 8ad7ad326affd2b3fa9eeb9c067a82ecd2dbbaf3 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Mon, 11 Jun 2012 19:22:05 +0200 Subject: [PATCH 25/91] Review comments from @bartvde. --- tests/Control/ZoomBox.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Control/ZoomBox.html b/tests/Control/ZoomBox.html index 9ee3fde886..2e037192e5 100644 --- a/tests/Control/ZoomBox.html +++ b/tests/Control/ZoomBox.html @@ -40,12 +40,13 @@ control.zoomBox(new OpenLayers.Bounds(128, 64, 256, 128)); t.eq(map.getCenter().toShortString(), "-45, 22.5", "centered to box center"); t.eq(map.getZoom(), 3, "zoomed to box extent"); + + map.destroy(); }
    -
    in
    out From 8208241e5571b0049669da186fbbb2de0d6fc094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Tue, 12 Jun 2012 22:03:11 +0200 Subject: [PATCH 26/91] fix the kml-pointtrack.html example --- examples/kml-pointtrack.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/kml-pointtrack.js b/examples/kml-pointtrack.js index 47836f25fd..7d48ce360f 100644 --- a/examples/kml-pointtrack.js +++ b/examples/kml-pointtrack.js @@ -29,12 +29,13 @@ function init() { var fid, points = [], feature; for (var i=0, len=e.features.length; i Date: Tue, 12 Jun 2012 22:35:12 +0200 Subject: [PATCH 27/91] set VERSION_NUMBER to 2.12-rc7 --- lib/OpenLayers.js | 2 +- lib/OpenLayers/SingleFile.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index e2922161e7..676549fca5 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -414,4 +414,4 @@ /** * Constant: VERSION_NUMBER */ -OpenLayers.VERSION_NUMBER="Release 2.12-rc6"; +OpenLayers.VERSION_NUMBER="Release 2.12-rc7"; diff --git a/lib/OpenLayers/SingleFile.js b/lib/OpenLayers/SingleFile.js index 797fc34394..ab5401ceb9 100644 --- a/lib/OpenLayers/SingleFile.js +++ b/lib/OpenLayers/SingleFile.js @@ -7,7 +7,7 @@ var OpenLayers = { /** * Constant: VERSION_NUMBER */ - VERSION_NUMBER: "Release 2.12-rc6", + VERSION_NUMBER: "Release 2.12-rc7", /** * Constant: singleFile From ff06ab64c664f9a15c8144e34556e4a9eac3a74b Mon Sep 17 00:00:00 2001 From: Jachym Cepicky Date: Tue, 12 Jun 2012 22:48:48 +0200 Subject: [PATCH 28/91] Added changes to Format/WPS*: BoundingBox for DescribeProcess, multiple outputs for Execute as well as Format.WPS.readers --- lib/OpenLayers/Format/WPSDescribeProcess.js | 4 + lib/OpenLayers/Format/WPSExecute.js | 140 +++++++++++++++++++- tests/Format/WPSDescribeProcess.html | 12 +- tests/Format/WPSExecute.html | 31 +++-- 4 files changed, 172 insertions(+), 15 deletions(-) diff --git a/lib/OpenLayers/Format/WPSDescribeProcess.js b/lib/OpenLayers/Format/WPSDescribeProcess.js index 9534a245c9..60cc4d68b1 100644 --- a/lib/OpenLayers/Format/WPSDescribeProcess.js +++ b/lib/OpenLayers/Format/WPSDescribeProcess.js @@ -127,6 +127,10 @@ OpenLayers.Format.WPSDescribeProcess = OpenLayers.Class( output.complexOutput = {}; this.readChildNodes(node, output.complexOutput); }, + "LiteralOutput": function(node, output) { + output.literalOutput = {}; + this.readChildNodes(node, output.literalOutput); + }, "Input": function(node, dataInputs) { var input = { maxOccurs: parseInt(node.getAttribute("maxOccurs")), diff --git a/lib/OpenLayers/Format/WPSExecute.js b/lib/OpenLayers/Format/WPSExecute.js index c4b2d79afd..257a77c8e6 100644 --- a/lib/OpenLayers/Format/WPSExecute.js +++ b/lib/OpenLayers/Format/WPSExecute.js @@ -93,6 +93,28 @@ OpenLayers.Format.WPSExecute = OpenLayers.Class(OpenLayers.Format.XML, { return OpenLayers.Format.XML.prototype.write.apply(this, [node]); }, + /** + * APIMethod: read + * Parse a WPS Execute and return an object with its information. + * + * Parameters: + * data - {String} or {DOMElement} data to read/parse. + * + * Returns: + * {Object} + */ + read: function(data) { + if(typeof data == "string") { + data = OpenLayers.Format.XML.prototype.read.apply(this, [data]); + } + if(data && data.nodeType == 9) { + data = data.documentElement; + } + var info = {}; + this.readNode(data, info); + return info; + }, + /** * Property: writers * As a compliment to the readers property, this structure contains public @@ -131,15 +153,20 @@ OpenLayers.Format.WPSExecute = OpenLayers.Class(OpenLayers.Format.XML, { status: responseDocument.status } }); - if (responseDocument.output) { - this.writeNode("wps:Output", responseDocument.output, node); + if (responseDocument.outputs) { + for (var i = 0, len = responseDocument.outputs.length; i < len; i++) { + this.writeNode("wps:Output", responseDocument.outputs[i], node); + } } return node; }, "Output": function(output) { var node = this.createElementNSPlus("wps:Output", { attributes: { - asReference: output.asReference + asReference: output.asReference, + mimeType: output.mimeType, + encoding: output.encoding, + schema: output.schema } }); this.writeNode("ows:Identifier", output.identifier, node); @@ -150,7 +177,9 @@ OpenLayers.Format.WPSExecute = OpenLayers.Class(OpenLayers.Format.XML, { "RawDataOutput": function(rawDataOutput) { var node = this.createElementNSPlus("wps:RawDataOutput", { attributes: { - mimeType: rawDataOutput.mimeType + mimeType: rawDataOutput.mimeType, + encoding: rawDataOutput.encoding, + schema: rawDataOutput.schema } }); this.writeNode("ows:Identifier", rawDataOutput.identifier, node); @@ -186,6 +215,8 @@ OpenLayers.Format.WPSExecute = OpenLayers.Class(OpenLayers.Format.XML, { this.writeNode("wps:LiteralData", data.literalData, node); } else if (data.complexData) { this.writeNode("wps:ComplexData", data.complexData, node); + } else if (data.boundingBoxData) { + this.writeNode("ows:BoundingBox", data.boundingBoxData, node); } return node; }, @@ -256,6 +287,107 @@ OpenLayers.Format.WPSExecute = OpenLayers.Class(OpenLayers.Format.XML, { "ogc": OpenLayers.Format.Filter.v1_1_0.prototype.writers.ogc, "ows": OpenLayers.Format.OWSCommon.v1_1_0.prototype.writers.ows }, + + /** + * 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: { + "wps": { + "ExecuteResponse": function(node, obj) { + obj.executeResponse = { + lang: node.getAttribute("lang"), + statusLocation: node.getAttribute("statusLocation"), + serviceInstance: node.getAttribute("serviceInstance"), + service: node.getAttribute("service") + }; + this.readChildNodes(node, obj.executeResponse); + }, + "Process":function(node,obj) { + obj.process = {}; + this.readChildNodes(node, obj.process); + }, + "Status":function(node,obj) { + obj.status = { + creationTime: node.getAttribute("creationTime") + }; + this.readChildNodes(node, obj.status); + + }, + "ProcessSucceeded": function(node,obj) { + obj.processSucceeded = true; + }, + "ProcessOutputs": function(node, processDescription) { + processDescription.processOutputs = []; + this.readChildNodes(node, processDescription.processOutputs); + }, + "Output": function(node, processOutputs) { + var output = {}; + this.readChildNodes(node, output); + processOutputs.push(output); + }, + "Reference": function(node, output) { + output.reference = { + href: node.getAttribute("href"), + mimeType: node.getAttribute("mimeType"), + encoding: node.getAttribute("encoding"), + schema: node.getAttribute("schema") + }; + }, + "Data": function(node, output) { + output.data = {}; + this.readChildNodes(node, output); + }, + "LiteralData": function(node, output) { + output.literalData = { + dataType: node.getAttribute("dataType"), + uom: node.getAttribute("uom"), + value: this.getChildValue(node) + }; + }, + "ComplexData": function(node, output) { + output.complexData = { + mimeType: node.getAttribute("mimeType"), + schema: node.getAttribute("schema"), + encoding: node.getAttribute("encoding"), + value: "" + }; + + // try to get *some* value, ignore the empty text values + if (this.isSimpleContent(node)) { + for(var child=node.firstChild; child; child=child.nextSibling) { + switch(child.nodeType) { + case 3: // text node + case 4: // cdata section + output.complexData.value += child.nodeValue; + } + } + } + else { + for(var child=node.firstChild; child; child=child.nextSibling) { + if (child.nodeType == 1) { + output.complexData.value = child; + } + } + } + + }, + "BoundingBox": function(node, output) { + output.boundingBoxData = { + dimensions: node.getAttribute("dimensions"), + crs: node.getAttribute("crs") + }; + this.readChildNodes(node, output.boundingBoxData); + } + }, + + // TODO: we should add Exception parsing here + "ows": OpenLayers.Format.OWSCommon.v1_1_0.prototype.readers["ows"] + }, CLASS_NAME: "OpenLayers.Format.WPSExecute" diff --git a/tests/Format/WPSDescribeProcess.html b/tests/Format/WPSDescribeProcess.html index c411f6267b..f52fd21372 100644 --- a/tests/Format/WPSDescribeProcess.html +++ b/tests/Format/WPSDescribeProcess.html @@ -4,7 +4,7 @@ From 58a83b0d17da731551163fed61c39ff8f9614679 Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Mon, 25 Jun 2012 13:44:35 +0200 Subject: [PATCH 48/91] Refactored vendor methods to it's own module --- lib/OpenLayers.js | 1 + lib/OpenLayers/Control/PinchZoom.js | 2 +- lib/OpenLayers/Util.js | 92 ------------------- lib/OpenLayers/Vendor.js | 136 ++++++++++++++++++++++++++++ tests/Util.html | 81 ----------------- tests/Vendor.html | 118 ++++++++++++++++++++++++ tests/list-tests.html | 1 + 7 files changed, 257 insertions(+), 174 deletions(-) create mode 100644 lib/OpenLayers/Vendor.js create mode 100644 tests/Vendor.html diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index 676549fca5..672ebdde97 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -132,6 +132,7 @@ jsFiles = [ "OpenLayers/BaseTypes/Class.js", "OpenLayers/Util.js", + "OpenLayers/Vendor.js", "OpenLayers/Animation.js", "OpenLayers/BaseTypes.js", "OpenLayers/BaseTypes/Bounds.js", diff --git a/lib/OpenLayers/Control/PinchZoom.js b/lib/OpenLayers/Control/PinchZoom.js index e7e3827e1d..44492d404d 100644 --- a/lib/OpenLayers/Control/PinchZoom.js +++ b/lib/OpenLayers/Control/PinchZoom.js @@ -162,7 +162,7 @@ OpenLayers.Control.PinchZoom = OpenLayers.Class(OpenLayers.Control, { */ applyTransform: function(transform) { var style = this.map.layerContainerDiv.style; - var transformProperty = OpenLayers.Util.getVendorPrefixedObj("transform"); + var transformProperty = OpenLayers.Vendor.stylePrefix("transform"); if (transformProperty) { style[transformProperty] = transform; } diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index 967c9fde99..562ca489f6 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -1501,98 +1501,6 @@ OpenLayers.Util.getBrowserName = function() { return OpenLayers.BROWSER_NAME; }; -/** - * Constant: VENDOR_PREFIXES - * {Array} A list of prefixes to test support for vendor-prefixed properties - */ -OpenLayers.Util.VENDOR_PREFIXES = ["", "O", "ms", "Moz", "Webkit"]; - -/** - * Method: getVendorPrefixedCss - * - * Parameters: - * property - {String} The standard CSS property name - * - * Returns: - * {String} The CSS property name supported by the browser or null if - * unsupported - */ -OpenLayers.Util.getVendorPrefixedCss = (function() { - var cache = {}; - - function domToCss(prefixedDom) { - return prefixedDom. - replace(/([A-Z])/g, function(c) { return "-" + c.toLowerCase(); }). - replace(/^ms-/, "-ms-"); - } - - return function(property) { - // clear cache for tests - if (property === "clear cache") { cache = {}; return; } - - if (cache[property] === undefined) { - var domProperty = property. - replace(/(-.)/g, function(c) { return c.charAt(1).toUpperCase(); }); - var prefixedDom = OpenLayers.Util.getVendorPrefixedObj(domProperty); - cache[property] = domToCss(prefixedDom); - } - return cache[property]; - }; -})(); - -/** - * Method: getVendorPrefixedObj - * - * Parameters: - * object - {Object} Optional object to test for vendor-prefixed properties. Defaults to a DIV's style object. - * property - {String} The standard DOM style property name - * - * Returns: - * {String} The DOM style property name supported by the browser or null if - * unsupported - */ -OpenLayers.Util.getVendorPrefixedObj = (function() { - var cache = {}; - - return function getVendorPrefixedObj(obj, property) { - // emulate method overloading - if (typeof obj === "string") { - return getVendorPrefixedObj(document.createElement("div").style, obj); - } - - // clear cache for tests - if (property === "clear cache") { cache = {}; return; } - - if (cache[property] === undefined) { - var tmpProp, - i = 0, - l = OpenLayers.Util.VENDOR_PREFIXES.length, - prefix, - isStyleObj = (typeof obj.cssText !== "undefined"); - - cache[property] = null; - for(var i=0,l=OpenLayers.Util.VENDOR_PREFIXES.length; i transform-origin + * or WebkitTransformOrigin -> -webkit-transform-origin + * + * Parameters: + * prefixedDom - {String} The property to convert + * + * Returns: + * {String} The CSS property + */ + function domToCss(prefixedDom) { + if (!prefixedDom) { return null; } + return prefixedDom. + replace(/([A-Z])/g, function(c) { return "-" + c.toLowerCase(); }). + replace(/^ms-/, "-ms-"); + } + + /** + * APIMethod: cssPrefix + * Detect which property is used for a CSS property + * + * Parameters: + * property - {String} The standard (unprefixed) CSS property name + * + * Returns: + * {String} The standard CSS property, prefixed property or null if not + * supported + */ + function cssPrefix(property) { + if (cssCache[property] === undefined) { + var domProperty = property. + replace(/(-[\s\S])/g, function(c) { return c.charAt(1).toUpperCase(); }); + var prefixedDom = stylePrefix(domProperty); + cssCache[property] = domToCss(prefixedDom); + } + return cssCache[property]; + } + + /** + * APIMethod: jsPrefix + * Detect which property is used for a JS property/method + * + * Parameters: + * obj - {Object} The object to test on + * property - {String} The standard (unprefixed) JS property name + * + * Returns: + * {String} The standard JS property, prefixed property or null if not + * supported + */ + function jsPrefix(obj, property) { + if (jsCache[property] === undefined) { + var tmpProp, + i = 0, + l = VENDOR_PREFIXES.length, + prefix, + isStyleObj = (typeof obj.cssText !== "undefined"); + + jsCache[property] = null; + for(var i=0,l=VENDOR_PREFIXES.length; i + + + Vendor.js Tests + + + + + + + \ No newline at end of file diff --git a/tests/list-tests.html b/tests/list-tests.html index c883ed34d7..0b544f22f7 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -231,6 +231,7 @@
  • Tween.html
  • Kinetic.html
  • Util.html
  • +
  • Vendor.html
  • deprecated/Ajax.html
  • deprecated/Util.html
  • deprecated/BaseTypes/Class.html
  • From ab6b2ef008203bc29c4eddaf231889baa889ed85 Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Mon, 25 Jun 2012 13:45:33 +0200 Subject: [PATCH 49/91] Use vendor detection for requestAnimationFrame --- lib/OpenLayers/Animation.js | 14 ++++---------- tests/Animation.html | 1 + 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/OpenLayers/Animation.js b/lib/OpenLayers/Animation.js index cadc14dedb..4a4ccc5637 100644 --- a/lib/OpenLayers/Animation.js +++ b/lib/OpenLayers/Animation.js @@ -5,6 +5,7 @@ * full text of the license. * * @requires OpenLayers/SingleFile.js + * @requires OpenLayers/Vendor.js */ /** @@ -19,11 +20,8 @@ OpenLayers.Animation = (function(window) { * Property: isNative * {Boolean} true if a native requestAnimationFrame function is available */ - var isNative = !!(window.requestAnimationFrame || - window.webkitRequestAnimationFrame || - window.mozRequestAnimationFrame || - window.oRequestAnimationFrame || - window.msRequestAnimationFrame); + var requestAnimationFrame = OpenLayers.Vendor.jsPrefix(window, "requestAnimationFrame"); + var isNative = !!(requestAnimationFrame); /** * Function: requestFrame @@ -36,11 +34,7 @@ OpenLayers.Animation = (function(window) { * element - {DOMElement} Optional element that visually bounds the animation. */ var requestFrame = (function() { - var request = window.requestAnimationFrame || - window.webkitRequestAnimationFrame || - window.mozRequestAnimationFrame || - window.oRequestAnimationFrame || - window.msRequestAnimationFrame || + var request = window[requestAnimationFrame] || function(callback, element) { window.setTimeout(callback, 16); }; diff --git a/tests/Animation.html b/tests/Animation.html index f113690933..b07308d3e0 100644 --- a/tests/Animation.html +++ b/tests/Animation.html @@ -6,6 +6,7 @@ // dependencies for tests var OpenLayers = [ + "OpenLayers/Vendor.js", "OpenLayers/Animation.js" ]; From 0e78d40da229350c272c37f09b90bdcd99bb18ee Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 25 Jun 2012 14:19:26 +0200 Subject: [PATCH 50/91] Update WMS base layer in strategy-cluster-threshold.html --- examples/strategy-cluster-threshold.html | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/strategy-cluster-threshold.html b/examples/strategy-cluster-threshold.html index 13abd2c1ea..a47e08d8e1 100644 --- a/examples/strategy-cluster-threshold.html +++ b/examples/strategy-cluster-threshold.html @@ -37,10 +37,8 @@ function init() { map = new OpenLayers.Map('map'); var base = new OpenLayers.Layer.WMS("OpenLayers WMS", - ["http://t3.tilecache.osgeo.org/wms-c/Basic.py", - "http://t2.tilecache.osgeo.org/wms-c/Basic.py", - "http://t1.tilecache.osgeo.org/wms-c/Basic.py"], - {layers: 'satellite'} + "http://vmap0.tiles.osgeo.org/wms/vmap0", + {layers: 'basic'} ); var style = new OpenLayers.Style({ From 8058a800ed102d0fe7deccfcb9020accd7425ac9 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 25 Jun 2012 14:56:40 +0200 Subject: [PATCH 51/91] mobile-wmts-vienna example: requestEncoding already set in defaults --- examples/mobile-wmts-vienna.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/mobile-wmts-vienna.js b/examples/mobile-wmts-vienna.js index 04cd9b4148..01de358fc1 100644 --- a/examples/mobile-wmts-vienna.js +++ b/examples/mobile-wmts-vienna.js @@ -163,13 +163,13 @@ var map; var doc = request.responseText, caps = format.read(doc); fmzk = format.createLayer(caps, OpenLayers.Util.applyDefaults( - {layer:"fmzk", requestEncoding:"REST", transitionEffect:"resize"}, defaults + {layer:"fmzk", transitionEffect:"resize"}, defaults )); aerial = format.createLayer(caps, OpenLayers.Util.applyDefaults( - {layer:"lb", requestEncoding:"REST", transitionEffect:"resize"}, defaults + {layer:"lb", transitionEffect:"resize"}, defaults )); labels = format.createLayer(caps, OpenLayers.Util.applyDefaults( - {layer:"beschriftung", requestEncoding:"REST", className:"nofade", isBaseLayer: false}, + {layer:"beschriftung", className:"nofade", isBaseLayer: false}, defaults )); map.addLayers([fmzk, aerial, labels]); From 81dffce4f45e54683c3d34e3d14990ab884fb600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Mon, 25 Jun 2012 14:55:44 +0200 Subject: [PATCH 52/91] remove unworking example in wmts-capabilities --- examples/wmts-capabilities.html | 6 ------ examples/wmts-capabilities.js | 37 --------------------------------- 2 files changed, 43 deletions(-) diff --git a/examples/wmts-capabilities.html b/examples/wmts-capabilities.html index 638d335a3c..58aabd5f20 100644 --- a/examples/wmts-capabilities.html +++ b/examples/wmts-capabilities.html @@ -27,14 +27,8 @@ implementations.

    -

    KVP version.

    -
    -

    REST version.

    - -
    -

    This example creates an OpenLayers.Layer.WMTS layer to based diff --git a/examples/wmts-capabilities.js b/examples/wmts-capabilities.js index d507d1bec0..0b2e011c99 100644 --- a/examples/wmts-capabilities.js +++ b/examples/wmts-capabilities.js @@ -1,14 +1,9 @@ OpenLayers.ProxyHost = "/proxy/?url="; var map, format; -var map2, format2; function init() { - /* - * KVP version - */ - format = new OpenLayers.Format.WMTSCapabilities({ /** * This particular service is not in compliance with the WMTS spec and @@ -60,36 +55,4 @@ function init() { map.addLayer(osm); map.addControl(new OpenLayers.Control.LayerSwitcher()); map.setCenter(new OpenLayers.LonLat(-13677832, 5213272), 13); - - - /* - * REST version - */ - format2 = new OpenLayers.Format.WMTSCapabilities(); - - OpenLayers.Request.GET({ - url: "http://wmts.geo.admin.ch/1.0.0/WMTSCapabilities.xml", - success: function(request) { - var doc = request.responseXML; - if (!doc || !doc.documentElement) { - doc = request.responseText; - } - var capabilities = format2.read(doc); - var layer = format2.createLayer(capabilities, { - layer: "ch.are.gemeindetyp-1990-9klassen", - // not avalable in the WMTS Capabilities in native projection - maxExtent: [485869.5728, 76443.1884, 837076.5648, 299941.7864] - }); - map2.addLayer(layer); - map2.setCenter(new OpenLayers.LonLat(540000, 160000), 17); - }, - failure: function() { - alert("Trouble getting capabilities doc"); - OpenLayers.Console.error.apply(OpenLayers.Console, arguments); - } - }); - - map2 = new OpenLayers.Map({ - div: "map2" - }); } From 293d173079712f95c10dea9c65b63837a7e5d109 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Mon, 25 Jun 2012 17:18:32 +0200 Subject: [PATCH 53/91] Simple example with an OSM map, a marker and a popup. --- examples/osm-marker-popup.html | 32 ++++++++++++++++++++++++++++ examples/osm-marker-popup.js | 39 ++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 examples/osm-marker-popup.html create mode 100644 examples/osm-marker-popup.js diff --git a/examples/osm-marker-popup.html b/examples/osm-marker-popup.html new file mode 100644 index 0000000000..8744ec811e --- /dev/null +++ b/examples/osm-marker-popup.html @@ -0,0 +1,32 @@ + + + + + + + OpenLayers OSM and Google Example + + + + + + +

    OSM with Marker and Popup

    +

    + Demonstrate use of an OSM layer with a marker and a popup. +

    +
    + openstreetmap osm marker popup +
    +
    +
    +

    + A common use case for OpenLayers is to display a marker at a + location on the map, and add some information in a popup. It + is also easy to add a tooltip with a short description. + See the + osm-marker-popup.js source to see how this is done. +

    +
    + + diff --git a/examples/osm-marker-popup.js b/examples/osm-marker-popup.js new file mode 100644 index 0000000000..e8f39b5357 --- /dev/null +++ b/examples/osm-marker-popup.js @@ -0,0 +1,39 @@ +var map; +function init() { + + // The overlay layer for our marker, with a simple diamond as symbol + var overlay = new OpenLayers.Layer.Vector('Overlay', { + styleMap: new OpenLayers.StyleMap({ + externalGraphic: '../img/marker.png', + graphicWidth: 20, graphicHeight: 24, graphicYOffset: -24, + title: '${tooltip}' + }) + }); + + // The location of our marker and popup. We usually think in geographic + // coordinates ('EPSG:4326'), but the map is projected ('EPSG:3857'). + var myLocation = new OpenLayers.Geometry.Point(10.2, 48.9) + .transform('EPSG:4326', 'EPSG:3857'); + + // We add the marker with a tooltip text to the overlay + overlay.addFeatures([ + new OpenLayers.Feature.Vector(myLocation, {tooltip: 'OpenLayers'}) + ]); + + // A popup with some information about our location + var popup = new OpenLayers.Popup.FramedCloud("Popup", + myLocation.getBounds().getCenterLonLat(), null, + 'We ' + + 'could be here.
    Or elsewhere.', null, + true // <-- true if we want a close (X) button, false otherwise + ); + + // Finally we create the map + map = new OpenLayers.Map({ + div: "map", projection: "EPSG:3857", + layers: [new OpenLayers.Layer.OSM(), overlay], + center: myLocation.getBounds().getCenterLonLat(), zoom: 15 + }); + // and add the popup to it. + map.addPopup(popup); +} From 419ead9191cdc59ce8bd65927cc8041d379dacfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Tue, 26 Jun 2012 16:09:38 +0200 Subject: [PATCH 54/91] fix projection syntax --- lib/OpenLayers/Format/WMTSCapabilities.js | 2 +- tests/Format/WMTSCapabilities/v1_0_0.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Format/WMTSCapabilities.js b/lib/OpenLayers/Format/WMTSCapabilities.js index 3ad1f72ba8..157042cb55 100644 --- a/lib/OpenLayers/Format/WMTSCapabilities.js +++ b/lib/OpenLayers/Format/WMTSCapabilities.js @@ -153,7 +153,7 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Vers } var projection = config.projection || matrixSet.supportedCRS.replace( - /urn:ogc:def:crs:(\w+):.+:(\w+)$/, "$1:$2"); + /urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, "$1:$3"); var units = config.units || projection === "EPSG:4326" ? "degrees" : "m" diff --git a/tests/Format/WMTSCapabilities/v1_0_0.html b/tests/Format/WMTSCapabilities/v1_0_0.html index 99dbcda238..81686b1fff 100644 --- a/tests/Format/WMTSCapabilities/v1_0_0.html +++ b/tests/Format/WMTSCapabilities/v1_0_0.html @@ -495,7 +495,7 @@ http://schemas.opengis.net/wmts/1.0/examples/wmtsGetCapabilities_response.xml 21781 - urn:ogc:def:crs:EPSG:21781 + urn:ogc:def:crs:EPSG::21781 0 14285750.5715 From 484eda2ee5116dd41c8572aacff26c17221bdd43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Tue, 26 Jun 2012 16:14:12 +0200 Subject: [PATCH 55/91] add alternate projection parsing --- tests/Format/WMTSCapabilities/v1_0_0.html | 174 ++++++++++++++++++++++ 1 file changed, 174 insertions(+) diff --git a/tests/Format/WMTSCapabilities/v1_0_0.html b/tests/Format/WMTSCapabilities/v1_0_0.html index 81686b1fff..43de62a077 100644 --- a/tests/Format/WMTSCapabilities/v1_0_0.html +++ b/tests/Format/WMTSCapabilities/v1_0_0.html @@ -232,6 +232,29 @@ t.eq(layer.params['TIME'], "2012", "correct params"); } + function test_parse_projection(t) { + t.plan(2); + + var format = new OpenLayers.Format.WMTSCapabilities(); + + var xml = document.getElementById("restsample-alternate-proj1").firstChild.nodeValue; + var doc = new OpenLayers.Format.XML().read(xml); + var caps = format.read(doc); + var layer = format.createLayer(caps, { + layer: "ch.are.agglomerationen_isolierte_staedte-2000", + matrixSet: "21781" + }); + t.eq(layer.projection.getCode(), "EPSG:21781", "correct projection"); + + xml = document.getElementById("restsample-alternate-proj2").firstChild.nodeValue; + doc = new OpenLayers.Format.XML().read(xml); + caps = format.read(doc); + layer = format.createLayer(caps, { + layer: "ch.are.agglomerationen_isolierte_staedte-2000", + matrixSet: "21781" + }); + t.eq(layer.projection.getCode(), "EPSG:21781", "correct projection"); + } @@ -528,5 +551,156 @@ http://schemas.opengis.net/wmts/1.0/examples/wmtsGetCapabilities_response.xml -->
    + +
    + +
    + From f40d677164c1044f41fecce0f9f4c65e68d5c15d Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Wed, 27 Jun 2012 11:07:41 +0200 Subject: [PATCH 56/91] Removed declaration of OpenLayers if it's not defined (already requires SingleFile.js) --- lib/OpenLayers/Vendor.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/OpenLayers/Vendor.js b/lib/OpenLayers/Vendor.js index 0bf23916e3..7b7d6e74f2 100644 --- a/lib/OpenLayers/Vendor.js +++ b/lib/OpenLayers/Vendor.js @@ -6,12 +6,11 @@ * * @requires OpenLayers/SingleFile.js */ - + /** * Namespace: OpenLayers.Vendor * A collection of utility functions to detect vendor prefixed features */ -var OpenLayers = OpenLayers || {}; OpenLayers.Vendor = (function() { "use strict"; From d1ed8bb952b427a439236d089de674bc36b29031 Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Wed, 27 Jun 2012 11:57:04 +0200 Subject: [PATCH 57/91] Removed duplicate declarations of i and l --- lib/OpenLayers/Vendor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/OpenLayers/Vendor.js b/lib/OpenLayers/Vendor.js index 7b7d6e74f2..47a477e910 100644 --- a/lib/OpenLayers/Vendor.js +++ b/lib/OpenLayers/Vendor.js @@ -81,7 +81,7 @@ OpenLayers.Vendor = (function() { isStyleObj = (typeof obj.cssText !== "undefined"); jsCache[property] = null; - for(var i=0,l=VENDOR_PREFIXES.length; i Date: Wed, 27 Jun 2012 12:39:47 +0200 Subject: [PATCH 58/91] Expose caches instead of _clearCache method --- lib/OpenLayers/Vendor.js | 6 ++---- tests/Vendor.html | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/OpenLayers/Vendor.js b/lib/OpenLayers/Vendor.js index 47a477e910..b0e271009c 100644 --- a/lib/OpenLayers/Vendor.js +++ b/lib/OpenLayers/Vendor.js @@ -124,10 +124,8 @@ OpenLayers.Vendor = (function() { stylePrefix: stylePrefix, // used for testing - _clearCache: function() { - cssCache = {}; - jsCache = {}; - }, + cssCache: cssCache, + jsCache: jsCache, _mockStyle: function(mock) { divStyle = mock; } diff --git a/tests/Vendor.html b/tests/Vendor.html index 2979d8d1aa..1e7b205d00 100644 --- a/tests/Vendor.html +++ b/tests/Vendor.html @@ -35,11 +35,18 @@ return el; };*/ + function clearCache(type) { + var cache = OpenLayers.Vendor[type.replace("style", "js") + "Cache"]; + for (var key in cache) { + delete cache[key]; + } + } + function curryTestPrefix(type) { return function(standardProp, expectedPrefix, msg) { var prefixedProp, err, method = type + "Prefix"; try { - OpenLayers.Vendor._clearCache(); + clearCache(type); var fakeStyle = { cssText: "" }; if (o.prop != null) { fakeStyle[o.prop] = o.val; @@ -90,22 +97,22 @@ testCssPrefix("multi-word", "-ms-multi-word", "CSS vendor prefix - multiple words for Internet Explorer"); // test vendor prefix on object - OpenLayers.Vendor._clearCache(); + clearCache("js"); t.eq( OpenLayers.Vendor.jsPrefix( {}, "unsupported" ), null, "Standard object property - unsupported"); - OpenLayers.Vendor._clearCache(); + clearCache("js"); t.eq( OpenLayers.Vendor.jsPrefix( { "test": true }, "test" ), "test", "Standard object property"); - OpenLayers.Vendor._clearCache(); + clearCache("js"); t.eq( OpenLayers.Vendor.jsPrefix( { "oTest": true }, "test" ), "oTest", "Standard object property"); - OpenLayers.Vendor._clearCache(); + clearCache("js"); t.eq( OpenLayers.Vendor.jsPrefix( { "msTest": true }, "test" ), "msTest", "Standard object property"); - OpenLayers.Vendor._clearCache(); + clearCache("js"); t.eq( OpenLayers.Vendor.jsPrefix( { "mozTest": true }, "test" ), "mozTest", "Standard object property"); - OpenLayers.Vendor._clearCache(); + clearCache("js"); t.eq( OpenLayers.Vendor.jsPrefix( { "webkitTest": true }, "test" ), "webkitTest", "Standard object property"); // unwrap document.createElement From 7f32342ec38002fb5ae516dd44874034acc506ab Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Wed, 27 Jun 2012 13:28:43 +0200 Subject: [PATCH 59/91] Moved OpenLayers.Vendor to OpenLayers.Util.vendorPrefix --- lib/OpenLayers.js | 2 +- lib/OpenLayers/Animation.js | 4 ++-- lib/OpenLayers/Control/PinchZoom.js | 3 ++- .../{Vendor.js => Util/vendorPrefix.js} | 7 +++--- tests/Animation.html | 2 +- tests/{Vendor.html => Util/vendorPrefix.html} | 24 +++++++++---------- tests/list-tests.html | 2 +- 7 files changed, 23 insertions(+), 21 deletions(-) rename lib/OpenLayers/{Vendor.js => Util/vendorPrefix.js} (96%) rename tests/{Vendor.html => Util/vendorPrefix.html} (77%) diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index 672ebdde97..0399d2c1fa 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -132,7 +132,7 @@ jsFiles = [ "OpenLayers/BaseTypes/Class.js", "OpenLayers/Util.js", - "OpenLayers/Vendor.js", + "OpenLayers/Util/vendorPrefix.js", "OpenLayers/Animation.js", "OpenLayers/BaseTypes.js", "OpenLayers/BaseTypes/Bounds.js", diff --git a/lib/OpenLayers/Animation.js b/lib/OpenLayers/Animation.js index 4a4ccc5637..3507652252 100644 --- a/lib/OpenLayers/Animation.js +++ b/lib/OpenLayers/Animation.js @@ -5,7 +5,7 @@ * full text of the license. * * @requires OpenLayers/SingleFile.js - * @requires OpenLayers/Vendor.js + * @requires OpenLayers/Util/vendorPrefix.js */ /** @@ -20,7 +20,7 @@ OpenLayers.Animation = (function(window) { * Property: isNative * {Boolean} true if a native requestAnimationFrame function is available */ - var requestAnimationFrame = OpenLayers.Vendor.jsPrefix(window, "requestAnimationFrame"); + var requestAnimationFrame = OpenLayers.Util.vendorPrefix.jsPrefix(window, "requestAnimationFrame"); var isNative = !!(requestAnimationFrame); /** diff --git a/lib/OpenLayers/Control/PinchZoom.js b/lib/OpenLayers/Control/PinchZoom.js index 44492d404d..d42cfd15ba 100644 --- a/lib/OpenLayers/Control/PinchZoom.js +++ b/lib/OpenLayers/Control/PinchZoom.js @@ -4,6 +4,7 @@ * full text of the license. */ /** + * @requires OpenLayers/Util/vendorPrefix.js * @requires OpenLayers/Handler/Pinch.js */ @@ -162,7 +163,7 @@ OpenLayers.Control.PinchZoom = OpenLayers.Class(OpenLayers.Control, { */ applyTransform: function(transform) { var style = this.map.layerContainerDiv.style; - var transformProperty = OpenLayers.Vendor.stylePrefix("transform"); + var transformProperty = OpenLayers.Util.vendorPrefix.stylePrefix("transform"); if (transformProperty) { style[transformProperty] = transform; } diff --git a/lib/OpenLayers/Vendor.js b/lib/OpenLayers/Util/vendorPrefix.js similarity index 96% rename from lib/OpenLayers/Vendor.js rename to lib/OpenLayers/Util/vendorPrefix.js index b0e271009c..2bb760725d 100644 --- a/lib/OpenLayers/Vendor.js +++ b/lib/OpenLayers/Util/vendorPrefix.js @@ -6,12 +6,13 @@ * * @requires OpenLayers/SingleFile.js */ - + +OpenLayers.Util = OpenLayers.Util || {}; /** - * Namespace: OpenLayers.Vendor + * Namespace: OpenLayers.Util.vendorPrefix * A collection of utility functions to detect vendor prefixed features */ -OpenLayers.Vendor = (function() { +OpenLayers.Util.vendorPrefix = (function() { "use strict"; var VENDOR_PREFIXES = ["", "O", "ms", "Moz", "Webkit"], diff --git a/tests/Animation.html b/tests/Animation.html index b07308d3e0..c24ae49363 100644 --- a/tests/Animation.html +++ b/tests/Animation.html @@ -6,7 +6,7 @@ // dependencies for tests var OpenLayers = [ - "OpenLayers/Vendor.js", + "OpenLayers/Util/vendorPrefix.js", "OpenLayers/Animation.js" ]; diff --git a/tests/Vendor.html b/tests/Util/vendorPrefix.html similarity index 77% rename from tests/Vendor.html rename to tests/Util/vendorPrefix.html index 1e7b205d00..7978a8a3fa 100644 --- a/tests/Vendor.html +++ b/tests/Util/vendorPrefix.html @@ -1,16 +1,16 @@ - Vendor.js Tests + vendorPrefix.js Tests - + From 5e0050cc9ac8755d6e4cd76d81807ce8c44e5c11 Mon Sep 17 00:00:00 2001 From: Gregers Gram Rygg Date: Wed, 27 Jun 2012 18:32:48 +0200 Subject: [PATCH 62/91] Fixed broken test --- tests/Projection.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Projection.html b/tests/Projection.html index 236871ab76..5864be5347 100644 --- a/tests/Projection.html +++ b/tests/Projection.html @@ -44,7 +44,7 @@ // conditionally mock up proj4js var hasProj = !!window.Proj4js; if (!hasProj) { - window.Proj4js = true; + window.Proj4js = {}; } proj1.proj = {defData: "+title= WGS84 +foo=bar +x=0"}; proj2.proj = {defData: "+title=FOO +foo=bar +x=0", srsCode: "FOO"}; From 301ed5c3ce902eccac1dde1071ad3824dcd7179c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 27 Jun 2012 21:55:37 +0200 Subject: [PATCH 63/91] 2.12 notes - explain how to disable hw accelerated animations (refs #542) --- notes/2.12.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/notes/2.12.md b/notes/2.12.md index 1cb4aab675..c79d9d57a4 100644 --- a/notes/2.12.md +++ b/notes/2.12.md @@ -95,6 +95,19 @@ Corresponding issues/pull requests: * https://github.com/openlayers/openlayers/pull/127 +Note: Issue #511 has reported that tile animation causes flickering/blinking in +the iOS native browser. Forcing the browser to use hardware-accelerated +animations fixed the issue, but #542 has reported that it also considerably +slows down freehand drawing on iOS. If you're experiencing this and want to +disable hardware-accelerated animations you can use the following rule in your +CSS: + + @media (-webkit-transform-3d) { + img.olTileImage { + -webkit-transform: none; + } + } + ## Tile Queue The tiling code has been overhauled so tile loading in grid layers is now done in a queue. From 0412410be0ec43dc9a5c258b640a793fad41bd88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 27 Jun 2012 22:56:31 +0200 Subject: [PATCH 64/91] set VERSION_NUMBER to Release 2.12 --- lib/OpenLayers.js | 2 +- lib/OpenLayers/SingleFile.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index 676549fca5..acd1abd2d4 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -414,4 +414,4 @@ /** * Constant: VERSION_NUMBER */ -OpenLayers.VERSION_NUMBER="Release 2.12-rc7"; +OpenLayers.VERSION_NUMBER="Release 2.12"; diff --git a/lib/OpenLayers/SingleFile.js b/lib/OpenLayers/SingleFile.js index ab5401ceb9..3e5d662331 100644 --- a/lib/OpenLayers/SingleFile.js +++ b/lib/OpenLayers/SingleFile.js @@ -7,7 +7,7 @@ var OpenLayers = { /** * Constant: VERSION_NUMBER */ - VERSION_NUMBER: "Release 2.12-rc7", + VERSION_NUMBER: "Release 2.12", /** * Constant: singleFile From 7b91c9c26fa0edcafcea4d886c4a83dfbe5fb84e Mon Sep 17 00:00:00 2001 From: dregade Date: Thu, 28 Jun 2012 17:16:22 +0200 Subject: [PATCH 65/91] fix size initialization and resolution/zoom usage --- lib/OpenLayers/Layer/Zoomify.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Layer/Zoomify.js b/lib/OpenLayers/Layer/Zoomify.js index 6179cccd14..b9ed54ff9b 100644 --- a/lib/OpenLayers/Layer/Zoomify.js +++ b/lib/OpenLayers/Layer/Zoomify.js @@ -105,6 +105,7 @@ OpenLayers.Layer.Zoomify = OpenLayers.Class(OpenLayers.Layer.Grid, { initializeZoomify: function( size ) { var imageSize = size.clone(); + this.size = size.clone(); var tiles = new OpenLayers.Size( Math.ceil( imageSize.w / this.standardTileSize ), Math.ceil( imageSize.h / this.standardTileSize ) @@ -195,10 +196,10 @@ OpenLayers.Layer.Zoomify = OpenLayers.Class(OpenLayers.Layer.Grid, { */ getURL: function (bounds) { bounds = this.adjustBounds(bounds); - var res = this.map.getResolution(); + var res = this.getServerResolution(); var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w)); var y = Math.round((this.tileOrigin.lat - bounds.top) / (res * this.tileSize.h)); - var z = this.map.getZoom(); + var z = this.getZoomForResolution( res ); var tileIndex = x + y * this.tierSizeInTiles[z].w + this.tileCountUpToTier[z]; var path = "TileGroup" + Math.floor( (tileIndex) / 256 ) + @@ -219,10 +220,10 @@ OpenLayers.Layer.Zoomify = OpenLayers.Class(OpenLayers.Layer.Grid, { getImageSize: function() { if (arguments.length > 0) { var bounds = this.adjustBounds(arguments[0]); - var res = this.map.getResolution(); + var res = this.getServerResolution(); var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w)); var y = Math.round((this.tileOrigin.lat - bounds.top) / (res * this.tileSize.h)); - var z = this.map.getZoom(); + var z = this.getZoomForResolution( res ); var w = this.standardTileSize; var h = this.standardTileSize; if (x == this.tierSizeInTiles[z].w -1 ) { From 74f9a943cc0d84c673c73130e71981f9ca94afb2 Mon Sep 17 00:00:00 2001 From: dregade Date: Fri, 29 Jun 2012 09:22:54 +0200 Subject: [PATCH 66/91] fix serverResolutions if not provided --- lib/OpenLayers/Layer/Zoomify.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Layer/Zoomify.js b/lib/OpenLayers/Layer/Zoomify.js index b9ed54ff9b..d0b482ab29 100644 --- a/lib/OpenLayers/Layer/Zoomify.js +++ b/lib/OpenLayers/Layer/Zoomify.js @@ -133,14 +133,18 @@ OpenLayers.Layer.Zoomify = OpenLayers.Class(OpenLayers.Layer.Grid, { this.tierImageSize.reverse(); this.numberOfTiers = this.tierSizeInTiles.length; - + var resolutions = [1]; this.tileCountUpToTier = [0]; for (var i = 1; i < this.numberOfTiers; i++) { + resolutions.unshift(Math.pow(2, i)); this.tileCountUpToTier.push( this.tierSizeInTiles[i-1].w * this.tierSizeInTiles[i-1].h + this.tileCountUpToTier[i-1] ); } + if (!this.serverResolutions) { + this.serverResolutions = resolutions; + } }, /** From b837d9bdf448ccb67ba7e8a72e2a07ad93065368 Mon Sep 17 00:00:00 2001 From: rdewit Date: Mon, 2 Jul 2012 15:00:50 +1000 Subject: [PATCH 67/91] Fixed typo in CSS code for overriding default tile animation. --- 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 0ffca1769f..b1bf6339e5 100644 --- a/notes/2.12.md +++ b/notes/2.12.md @@ -72,7 +72,7 @@ The displaying of tiles can now be animated, using CSS3 transitions. Transitions People can override this rule to use other transition settings. To remove tile animation entirely use: - .olLayerGridTile .olTileImage { + .olLayerGrid .olTileImage { -webkit-transition: none; -moz-transition: none; -o-transition: all 0 none; From 0144a9473e43de5f59dd8f94d726a6b74af5ff6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Mon, 2 Jul 2012 16:33:40 +0200 Subject: [PATCH 68/91] Set VERSION_NUMBER to Release 2.13 dev --- lib/OpenLayers.js | 2 +- lib/OpenLayers/SingleFile.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index a3dbb63ae2..c8c80d847f 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -415,4 +415,4 @@ /** * Constant: VERSION_NUMBER */ -OpenLayers.VERSION_NUMBER="Release 2.12"; +OpenLayers.VERSION_NUMBER="Release 2.13 dev"; diff --git a/lib/OpenLayers/SingleFile.js b/lib/OpenLayers/SingleFile.js index 3e5d662331..2de1dc8940 100644 --- a/lib/OpenLayers/SingleFile.js +++ b/lib/OpenLayers/SingleFile.js @@ -7,7 +7,7 @@ var OpenLayers = { /** * Constant: VERSION_NUMBER */ - VERSION_NUMBER: "Release 2.12", + VERSION_NUMBER: "Release 2.13 dev", /** * Constant: singleFile From f7860a329c1c8f03667ba3cfb8ddbe04f7f636a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Tue, 3 Jul 2012 08:44:03 +0200 Subject: [PATCH 69/91] WMTS capabilities format - make the mid var local to the createLayer function --- lib/OpenLayers/Format/WMTSCapabilities.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/OpenLayers/Format/WMTSCapabilities.js b/lib/OpenLayers/Format/WMTSCapabilities.js index 157042cb55..aedd5e804d 100644 --- a/lib/OpenLayers/Format/WMTSCapabilities.js +++ b/lib/OpenLayers/Format/WMTSCapabilities.js @@ -159,7 +159,7 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Vers var resolutions = []; if (config.isBaseLayer !== false) { - for (mid in matrixSet.matrixIds) { + for (var mid in matrixSet.matrixIds) { if (matrixSet.matrixIds.hasOwnProperty(mid)) { resolutions.push( matrixSet.matrixIds[mid].scaleDenominator * 0.28E-3 From 90d3c2d9a9d265126c4765db19dc16eba7d4dbdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Tue, 3 Jul 2012 08:44:22 +0200 Subject: [PATCH 70/91] WMTS capabilities format - make JSLint happier --- lib/OpenLayers/Format/WMTSCapabilities.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Format/WMTSCapabilities.js b/lib/OpenLayers/Format/WMTSCapabilities.js index aedd5e804d..6f8795bfad 100644 --- a/lib/OpenLayers/Format/WMTSCapabilities.js +++ b/lib/OpenLayers/Format/WMTSCapabilities.js @@ -155,16 +155,16 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Vers var projection = config.projection || matrixSet.supportedCRS.replace( /urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, "$1:$3"); var units = config.units || - projection === "EPSG:4326" ? "degrees" : "m" + projection === "EPSG:4326" ? "degrees" : "m"; var resolutions = []; if (config.isBaseLayer !== false) { for (var mid in matrixSet.matrixIds) { if (matrixSet.matrixIds.hasOwnProperty(mid)) { resolutions.push( - matrixSet.matrixIds[mid].scaleDenominator * 0.28E-3 - / OpenLayers.METERS_PER_INCH - / OpenLayers.INCHES_PER_UNIT[units]); + matrixSet.matrixIds[mid].scaleDenominator * 0.28E-3 / + OpenLayers.METERS_PER_INCH / + OpenLayers.INCHES_PER_UNIT[units]); } } } From 679111fa8867dc0317fefea2754e90a0b003cd21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Tue, 3 Jul 2012 08:57:05 +0200 Subject: [PATCH 71/91] release.sh script - do not remove the build/closure-compiler folder --- tools/release.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/release.sh b/tools/release.sh index b7c4eef47f..125065b0da 100755 --- a/tools/release.sh +++ b/tools/release.sh @@ -41,8 +41,6 @@ mv ../../compiler.jar ../tools/closure-compiler.jar ./build.py -c none mobile OpenLayers.mobile.debug.js ./build.py -c none light OpenLayers.light.debug.js mv OpenLayers*.js ../ -rm -rf closure-compiler -rm closure*.py rm ../tools/closure-compiler.jar cd .. From 9be8bb2416214e83d293d0845f624146aa6420c2 Mon Sep 17 00:00:00 2001 From: Xavier Mamano Date: Sun, 8 Jul 2012 23:50:52 +0200 Subject: [PATCH 72/91] Fix typo "_onImageLoad" is "_onImgLoad" --- lib/OpenLayers/Popup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/OpenLayers/Popup.js b/lib/OpenLayers/Popup.js index 2955766608..cc6cdea37d 100644 --- a/lib/OpenLayers/Popup.js +++ b/lib/OpenLayers/Popup.js @@ -694,7 +694,7 @@ OpenLayers.Popup = OpenLayers.Class({ } OpenLayers.Event.stopObserving( - this.img, "load", this.img._onImageLoad + this.img, "load", this.img._onImgLoad ); }; From a45cbfdb074abb8d69a09224ff655626f5728c5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Thu, 12 Jul 2012 18:32:30 +0200 Subject: [PATCH 73/91] use minus sign --- lib/OpenLayers/Control/Zoom.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Control/Zoom.js b/lib/OpenLayers/Control/Zoom.js index 37ac48ce66..c12d05a103 100644 --- a/lib/OpenLayers/Control/Zoom.js +++ b/lib/OpenLayers/Control/Zoom.js @@ -37,9 +37,9 @@ OpenLayers.Control.Zoom = OpenLayers.Class(OpenLayers.Control, { /** * APIProperty: zoomOutText * {String} - * Text for zoom-out link. Default is "-". + * Text for zoom-out link. Default is "−". */ - zoomOutText: "-", + zoomOutText: "−", /** * APIProperty: zoomOutId From 99553d0ae5d6c61ace718e8f915138f050bf715a Mon Sep 17 00:00:00 2001 From: Pierre GIRAUD Date: Tue, 17 Jul 2012 16:15:03 +0300 Subject: [PATCH 74/91] Fixing doc. No functional change. --- lib/OpenLayers/Control/Snapping.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/OpenLayers/Control/Snapping.js b/lib/OpenLayers/Control/Snapping.js index ec75f6d66c..9e87043532 100644 --- a/lib/OpenLayers/Control/Snapping.js +++ b/lib/OpenLayers/Control/Snapping.js @@ -124,7 +124,7 @@ OpenLayers.Control.Snapping = OpenLayers.Class(OpenLayers.Control, { * objects below. If the items in the targets list are vector layers * (instead of configuration objects), the defaults from the * property will apply. The editable layer itself may be a target - * layer - allowing newly created or edited features to be snapped to + * layer, allowing newly created or edited features to be snapped to * existing features from the same layer. If no targets are provided * the layer given in the constructor (as ) will become the * initial target. From 950904f59a9057f1b9211708911e3de08f2afdcf Mon Sep 17 00:00:00 2001 From: temporaryaccount Date: Thu, 19 Jul 2012 18:08:30 +0400 Subject: [PATCH 75/91] Prevent KeyboardDefaults.js from triggering keyboard events when user is typing into the form elements --- lib/OpenLayers/Control/KeyboardDefaults.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/OpenLayers/Control/KeyboardDefaults.js b/lib/OpenLayers/Control/KeyboardDefaults.js index b973b3d6bf..8b1d4e17a3 100644 --- a/lib/OpenLayers/Control/KeyboardDefaults.js +++ b/lib/OpenLayers/Control/KeyboardDefaults.js @@ -75,6 +75,14 @@ OpenLayers.Control.KeyboardDefaults = OpenLayers.Class(OpenLayers.Control, { */ defaultKeyPress: function (evt) { var size, handled = true; + + if((typeof evt.target) != 'undefined' && + (evt.target.tagName == 'INPUT' || + evt.target.tagName == 'TEXTAREA' || + evt.target.tagName == 'SELECT')) { + return; + } + switch(evt.keyCode) { case OpenLayers.Event.KEY_LEFT: this.map.pan(-this.slideFactor, 0); From c7869522191d800bd325f2f47c8919b590da0707 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Fri, 20 Jul 2012 09:19:20 +0200 Subject: [PATCH 76/91] Fixing tests. --- tests/Format/GPX.html | 6 ++++++ tests/Layer/Bing.html | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/Format/GPX.html b/tests/Format/GPX.html index ee08de9556..6286cfe395 100644 --- a/tests/Format/GPX.html +++ b/tests/Format/GPX.html @@ -20,6 +20,10 @@ } function test_Format_GPX_read(t) { t.plan(7); + + var origDefaultPrecision = OpenLayers.Util.DEFAULT_PRECISION; + OpenLayers.Util.DEFAULT_PRECISION = 9; + var expected, P = OpenLayers.Geometry.Point, LS = OpenLayers.Geometry.LineString; @@ -61,6 +65,8 @@ new P(-19493.373203291227, 6684644.845706556) ]); t.geom_eq(features[1].geometry, expected, "transformed route feature correctly created"); + + OpenLayers.Util.DEFAULT_PRECISION = origDefaultPrecision; } function test_format_GPX_read_attributes(t) { t.plan(2); diff --git a/tests/Layer/Bing.html b/tests/Layer/Bing.html index b37de906fd..69525df7a5 100644 --- a/tests/Layer/Bing.html +++ b/tests/Layer/Bing.html @@ -126,9 +126,9 @@ map.zoomToMaxExtent(); t.delay_call(2, function() { - t.ok(layer.attribution.indexOf('olBingAttribution aerial') !== -1, "Attribution has the correct css class"); - t.ok(layer.attribution.indexOf('') == -1, "Attribution contains a logo"); - t.ok(layer.attribution.indexOf('
    ') == -1, "Attribution contains a logo"); + t.ok(OpenLayers.Util.indexOf(layer.attribution, '
    OpenStreetMap" }), new OpenLayers.Layer.XYZ("OSM (without buffer)", urls, { - transitionEffect: "resize", buffer: 0, sphericalMercator: true + transitionEffect: "resize", buffer: 0, sphericalMercator: true, + attribution: "Data CC-By-SA by OpenStreetMap" }) ], controls: [ From 9d31c57e2a3a4b9fa0521639182413e922b45b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Mon, 30 Jul 2012 23:17:11 +0200 Subject: [PATCH 79/91] correct units in WMTS capabilities --- lib/OpenLayers/Format/WMTSCapabilities.js | 2 +- tests/Format/WMTSCapabilities/v1_0_0.html | 33 ++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Format/WMTSCapabilities.js b/lib/OpenLayers/Format/WMTSCapabilities.js index 6f8795bfad..2b8c5e9ce1 100644 --- a/lib/OpenLayers/Format/WMTSCapabilities.js +++ b/lib/OpenLayers/Format/WMTSCapabilities.js @@ -155,7 +155,7 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Vers var projection = config.projection || matrixSet.supportedCRS.replace( /urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, "$1:$3"); var units = config.units || - projection === "EPSG:4326" ? "degrees" : "m"; + (projection === "EPSG:4326" ? "degrees" : "m"); var resolutions = []; if (config.isBaseLayer !== false) { diff --git a/tests/Format/WMTSCapabilities/v1_0_0.html b/tests/Format/WMTSCapabilities/v1_0_0.html index 43de62a077..cb4b55c7d9 100644 --- a/tests/Format/WMTSCapabilities/v1_0_0.html +++ b/tests/Format/WMTSCapabilities/v1_0_0.html @@ -140,7 +140,7 @@ } function test_createLayer(t) { - t.plan(27); + t.plan(34); var format = new OpenLayers.Format.WMTSCapabilities(); @@ -230,6 +230,37 @@ t.eq(layer.dimensions.length, 1, "correct dimensions length"); t.eq(layer.dimensions[0], "Time", "correct dimensions"); t.eq(layer.params['TIME'], "2012", "correct params"); + + // test projection and units + layer = format.createLayer(caps, { + layer: "ch.are.agglomerationen_isolierte_staedte-2000", + matrixSet: "21781", + units: 'degrees' + }); + t.eq(layer.units, "degrees", "correct units"); + layer = format.createLayer(caps, { + layer: "ch.are.agglomerationen_isolierte_staedte-2000", + matrixSet: "21781", + projection: "EPSG:4326" + }); + t.eq(layer.projection.getCode(), "EPSG:4326", "correct projection"); + t.eq(layer.units, "degrees", "correct units"); + layer = format.createLayer(caps, { + layer: "ch.are.agglomerationen_isolierte_staedte-2000", + matrixSet: "21781", + projection: "EPSG:4326", + units: 'm' + }); + t.eq(layer.projection.getCode(), "EPSG:4326", "correct projection"); + t.eq(layer.units, "m", "correct units"); + layer = format.createLayer(caps, { + layer: "ch.are.agglomerationen_isolierte_staedte-2000", + matrixSet: "21781", + projection: "EPSG:900913", + units: 'degrees' + }); + t.eq(layer.projection.getCode(), "EPSG:900913", "correct projection"); + t.eq(layer.units, "degrees", "correct units"); } function test_parse_projection(t) { From 98569203a6afe67f6060f1dc54cf564710e3caf9 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Wed, 1 Aug 2012 10:20:25 +0200 Subject: [PATCH 80/91] Check whether an event target should be considered for handling. --- lib/OpenLayers/Events/buttonclick.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/OpenLayers/Events/buttonclick.js b/lib/OpenLayers/Events/buttonclick.js index e2a3edad62..e0b2a87514 100644 --- a/lib/OpenLayers/Events/buttonclick.js +++ b/lib/OpenLayers/Events/buttonclick.js @@ -121,6 +121,26 @@ OpenLayers.Events.buttonclick = OpenLayers.Class({ } while(--depth > 0 && element); return button; }, + + /** + * Method: ignore + * Check for event target elements that should be ignored by OpenLayers. + * + * Parameters: + * element - {DOMElement} The event target. + */ + ignore: function(element) { + var depth = 3, + ignore = false; + do { + if (element.nodeName.toLowerCase() === 'a') { + ignore = true; + break; + } + element = element.parentNode; + } while (--depth > 0 && element); + return ignore; + }, /** * Method: buttonClick @@ -170,6 +190,7 @@ OpenLayers.Events.buttonclick = OpenLayers.Class({ propagate = false; } } else { + propagate = !this.ignore(OpenLayers.Event.element(evt)); delete this.startEvt; } } From aef5517bfad33faed860047bce59dabaa917ffe7 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Wed, 1 Aug 2012 13:15:59 +0200 Subject: [PATCH 81/91] Adding unit tests. --- tests/Events/buttonclick.html | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/Events/buttonclick.html b/tests/Events/buttonclick.html index 35ebb81f8a..dadbd3a746 100644 --- a/tests/Events/buttonclick.html +++ b/tests/Events/buttonclick.html @@ -63,6 +63,40 @@ events.destroy(); } + function test_ignore(t) { + t.plan(5); + + // set up + + events = new OpenLayers.Events({}, element); + buttonClick = new OpenLayers.Events.buttonclick(events); + + var link = document.createElement('a'), + span1 = document.createElement('span'), + span2 = document.createElement('span'), + span3 = document.createElement('span'); + link.appendChild(span1); + span1.appendChild(span2); + span2.appendChild(span3); + + t.eq(buttonClick.ignore(link), true, + 'ignore returns true when element is a link'); + t.eq(buttonClick.ignore(span1), true, + 'ignore returns true when element is link descendant level 1'); + t.eq(buttonClick.ignore(span2), true, + 'ignore returns true when element is link descendant level 2'); + t.eq(buttonClick.ignore(span3), false, + 'ignore returns false when element is link descendant level 3'); + t.eq(buttonClick.ignore(element), false, + 'ignore returns false when element is not a link'); + + + // tear down + + buttonClick.destroy(); + events.destroy(); + } + function test_ButtonClick_buttonClick(t) { t.plan(27); events = new OpenLayers.Events({}, element); From bab1858bfc6291e2ecf02a1b99bf9bcda1659b68 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Wed, 8 Aug 2012 09:20:14 +0200 Subject: [PATCH 82/91] slightly modify the wfs-states example to show how to switch between a WMS and a vector layer at a certain scale (non-functional change) --- examples/wfs-states.html | 3 ++- examples/wfs-states.js | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/wfs-states.html b/examples/wfs-states.html index 655acd4429..ffe6c87bbe 100644 --- a/examples/wfs-states.html +++ b/examples/wfs-states.html @@ -22,7 +22,8 @@

    This example shows the basic use of a vector layer with the - WFS protocol. + WFS protocol, and shows how to switch between a WMS and a vector + layer at a certain scale.

    See the wfs-states.js diff --git a/examples/wfs-states.js b/examples/wfs-states.js index 6bdb499227..c4e801e6cf 100644 --- a/examples/wfs-states.js +++ b/examples/wfs-states.js @@ -13,7 +13,13 @@ function init() { "http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: "basic"} ), + new OpenLayers.Layer.WMS("States WMS", + "http://demo.opengeo.org/geoserver/wms", + {layers: "topp:states", format: "image/png", transparent: true}, + {maxScale: 15000000} + ), new OpenLayers.Layer.Vector("States", { + minScale: 15000000, strategies: [new OpenLayers.Strategy.BBOX()], protocol: new OpenLayers.Protocol.WFS({ url: "http://demo.opengeo.org/geoserver/wfs", From 269649444337041fed70d09409dbb39441ff9c62 Mon Sep 17 00:00:00 2001 From: Donald Curtis Date: Tue, 7 Aug 2012 14:48:14 -0500 Subject: [PATCH 83/91] return response object on "loadend" event for Fixed and BBOX strategies --- lib/OpenLayers/Layer.js | 6 ++++-- lib/OpenLayers/Strategy/BBOX.js | 2 +- lib/OpenLayers/Strategy/Fixed.js | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js index 2c29e72c4b..e381a353db 100644 --- a/lib/OpenLayers/Layer.js +++ b/lib/OpenLayers/Layer.js @@ -87,7 +87,9 @@ OpenLayers.Layer = OpenLayers.Class({ * * Supported map event types: * loadstart - Triggered when layer loading starts. - * loadend - Triggered when layer loading ends. + * loadend - Triggered when layer loading ends. When using Fixed or BBOX + * strategies, the event object includes a *response* property holding + * an OpenLayers.Protocol.Response object. * visibilitychanged - Triggered when layer visibility is changed. * move - Triggered when layer moves (triggered with every mousemove * during a drag). @@ -119,7 +121,7 @@ OpenLayers.Layer = OpenLayers.Class({ /** * Property: alpha - * {Boolean} The layer's images have an alpha channel. Default is false. + * {Boolean} The layer's images have an alpha channel. Default is false. */ alpha: false, diff --git a/lib/OpenLayers/Strategy/BBOX.js b/lib/OpenLayers/Strategy/BBOX.js index 6df04b1a03..3ea357050a 100644 --- a/lib/OpenLayers/Strategy/BBOX.js +++ b/lib/OpenLayers/Strategy/BBOX.js @@ -278,7 +278,7 @@ OpenLayers.Strategy.BBOX = OpenLayers.Class(OpenLayers.Strategy, { this.layer.addFeatures(features); } this.response = null; - this.layer.events.triggerEvent("loadend"); + this.layer.events.triggerEvent("loadend", {response: resp}); }, CLASS_NAME: "OpenLayers.Strategy.BBOX" diff --git a/lib/OpenLayers/Strategy/Fixed.js b/lib/OpenLayers/Strategy/Fixed.js index 0893b0d895..ea81f5ed2a 100644 --- a/lib/OpenLayers/Strategy/Fixed.js +++ b/lib/OpenLayers/Strategy/Fixed.js @@ -124,7 +124,7 @@ OpenLayers.Strategy.Fixed = OpenLayers.Class(OpenLayers.Strategy, { } layer.addFeatures(features); } - layer.events.triggerEvent("loadend"); + layer.events.triggerEvent("loadend", {response: resp}); }, CLASS_NAME: "OpenLayers.Strategy.Fixed" From 4ae9f6878db92564f77abef0a321cfdd29e15103 Mon Sep 17 00:00:00 2001 From: tschaub Date: Wed, 8 Aug 2012 11:23:02 -0600 Subject: [PATCH 84/91] Making events easier to test. This should make it more straightforward to test the new event properties being sent with loadend on BBOX and Fixed strategies (see #624). --- tests/Strategy/BBOX.html | 30 +++++++++++++++--------------- tests/Strategy/Fixed.html | 28 ++++++++++++++-------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/tests/Strategy/BBOX.html b/tests/Strategy/BBOX.html index 4194b59175..a36f24c6dc 100644 --- a/tests/Strategy/BBOX.html +++ b/tests/Strategy/BBOX.html @@ -112,11 +112,9 @@ function test_events(t) { - t.plan(3); - var log = { - loadstart: 0, - loadend: 0 - }; + t.plan(5); + + var log = []; var map = new OpenLayers.Map("map"); var layer = new OpenLayers.Layer.Vector(null, { @@ -128,27 +126,29 @@ }), isBaseLayer: true, eventListeners: { - loadstart: function() { - ++log.loadstart; + loadstart: function(event) { + log.push(event); }, - loadend: function() { - ++log.loadend; + loadend: function(event) { + log.push(event); } } }); map.addLayer(layer); map.zoomToMaxExtent(); + + t.eq(log.length, 2, "2 events logged"); + t.eq(log[0].type, "loadstart", "loadstart first"); + t.eq(log[1].type, "loadend", "loadend second"); - t.eq(log.loadstart, 1, "loadstart triggered"); - t.eq(log.loadend, 1, "loadend triggered"); - - log = {}; + var calls = []; layer.protocol.read = function(obj) { - log.obj = obj; + calls.push(obj); } layer.refresh({force: true, whee: 'chicken'}); - t.eq(log.obj && log.obj.whee, "chicken", "properties passed to read on refresh correctly."); + t.eq(calls.length, 1, "1 call to read"); + t.eq(calls[0].whee, "chicken", "properties passed to read"); map.destroy(); diff --git a/tests/Strategy/Fixed.html b/tests/Strategy/Fixed.html index 209d8daab6..2312a416f3 100644 --- a/tests/Strategy/Fixed.html +++ b/tests/Strategy/Fixed.html @@ -62,12 +62,9 @@ function test_events(t) { - t.plan(3); + t.plan(5); - var log = { - loadstart: 0, - loadend: 0 - }; + var log = []; var map = new OpenLayers.Map("map"); var layer = new OpenLayers.Layer.Vector(null, { @@ -79,11 +76,11 @@ }), isBaseLayer: true, eventListeners: { - loadstart: function() { - ++log.loadstart; + loadstart: function(event) { + log.push(event); }, - loadend: function() { - ++log.loadend; + loadend: function(event) { + log.push(event); } } }); @@ -91,15 +88,18 @@ map.addLayer(layer); map.zoomToMaxExtent(); - t.eq(log.loadstart, 1, "loadstart triggered"); - t.eq(log.loadend, 1, "loadend triggered"); - var log = {}; + t.eq(log.length, 2, "2 events logged"); + t.eq(log[0].type, "loadstart", "loadstart first"); + t.eq(log[1].type, "loadend", "loadend second"); + + var calls = []; layer.protocol.read = function(obj) { - log.obj = obj; + calls.push(obj); } layer.refresh({whee: 'chicken'}); - t.eq(log.obj && log.obj.whee, "chicken", "properties passed to read on refresh correctly."); + t.eq(calls.length, 1, "1 call to read"); + t.eq(calls[0].whee, "chicken", "properties passed to read"); map.destroy(); From 7e326f97e2e9b4360d0511cc725229a03a410d15 Mon Sep 17 00:00:00 2001 From: tschaub Date: Wed, 8 Aug 2012 11:41:33 -0600 Subject: [PATCH 85/91] Doc fix for merge method. --- lib/OpenLayers/Strategy/Fixed.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Strategy/Fixed.js b/lib/OpenLayers/Strategy/Fixed.js index ea81f5ed2a..6b38b0b9c9 100644 --- a/lib/OpenLayers/Strategy/Fixed.js +++ b/lib/OpenLayers/Strategy/Fixed.js @@ -106,7 +106,8 @@ OpenLayers.Strategy.Fixed = OpenLayers.Class(OpenLayers.Strategy, { * * Parameters: * mapProjection - {} the map projection - * resp - {Object} options to pass to protocol read. + * resp - {} The response object passed + * by the protocol. */ merge: function(mapProjection, resp) { var layer = this.layer; From 970448effc0bdaffa3fb40ca7c4115e98e2901d8 Mon Sep 17 00:00:00 2001 From: tschaub Date: Wed, 8 Aug 2012 11:41:51 -0600 Subject: [PATCH 86/91] Tests for response property on loadend event. This confirms that the loadend event includes a response property when it results from a call to the strategy merge method (see #624). --- tests/Strategy/BBOX.html | 7 +++++-- tests/Strategy/Fixed.html | 9 ++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/Strategy/BBOX.html b/tests/Strategy/BBOX.html index a36f24c6dc..b89e5568cf 100644 --- a/tests/Strategy/BBOX.html +++ b/tests/Strategy/BBOX.html @@ -112,16 +112,18 @@ function test_events(t) { - t.plan(5); + t.plan(6); var log = []; + var response = new OpenLayers.Protocol.Response(); + var map = new OpenLayers.Map("map"); var layer = new OpenLayers.Layer.Vector(null, { strategies: [new OpenLayers.Strategy.BBOX()], protocol: new OpenLayers.Protocol({ read: function(config) { - config.callback.call(config.scope, {}); + config.callback.call(config.scope, response); } }), isBaseLayer: true, @@ -140,6 +142,7 @@ t.eq(log.length, 2, "2 events logged"); t.eq(log[0].type, "loadstart", "loadstart first"); t.eq(log[1].type, "loadend", "loadend second"); + t.ok(log[1].response == response, "loadend includes response"); var calls = []; layer.protocol.read = function(obj) { diff --git a/tests/Strategy/Fixed.html b/tests/Strategy/Fixed.html index 2312a416f3..2f9f5b3adc 100644 --- a/tests/Strategy/Fixed.html +++ b/tests/Strategy/Fixed.html @@ -62,16 +62,18 @@ function test_events(t) { - t.plan(5); + t.plan(6); var log = []; + + var response = new OpenLayers.Protocol.Response(); var map = new OpenLayers.Map("map"); var layer = new OpenLayers.Layer.Vector(null, { strategies: [new OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol({ read: function(config) { - config.callback.call(config.scope, {}); + config.callback.call(config.scope, response); } }), isBaseLayer: true, @@ -87,10 +89,11 @@ map.addLayer(layer); map.zoomToMaxExtent(); - + t.eq(log.length, 2, "2 events logged"); t.eq(log[0].type, "loadstart", "loadstart first"); t.eq(log[1].type, "loadend", "loadend second"); + t.ok(log[1].response == response, "loadend includes response"); var calls = []; layer.protocol.read = function(obj) { From 5cf260f38a878965ae6aee48aaff983af4d21809 Mon Sep 17 00:00:00 2001 From: tschaub Date: Tue, 14 Aug 2012 11:01:58 -0600 Subject: [PATCH 87/91] Add missing requires (closes #633). --- lib/OpenLayers/Control/OverviewMap.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/OpenLayers/Control/OverviewMap.js b/lib/OpenLayers/Control/OverviewMap.js index 55af687d08..c075a45577 100644 --- a/lib/OpenLayers/Control/OverviewMap.js +++ b/lib/OpenLayers/Control/OverviewMap.js @@ -7,6 +7,9 @@ * @requires OpenLayers/Control.js * @requires OpenLayers/BaseTypes.js * @requires OpenLayers/Events/buttonclick.js + * @requires OpenLayers/Map.js + * @requires OpenLayers/Handler/Click.js + * @requires OpenLayers/Handler/Drag.js */ /** From 39a6d7d8ef42860ff9d726af27715454573fb335 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Thu, 16 Aug 2012 14:21:36 +0200 Subject: [PATCH 88/91] fix issue with orientation changes on mobile devices (tested on Motorola Xoom 2 with Android 3.2.2 in the stock browser) --- lib/OpenLayers/Map.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index ab2cc1a928..ed90015b61 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -588,8 +588,13 @@ OpenLayers.Map = OpenLayers.Class({ // Else updateSize on catching the window's resize // Note that this is ok, as updateSize() does nothing if the // map's size has not actually changed. - this.updateSizeDestroy = OpenLayers.Function.bind(this.updateSize, - this); + var me = this; + // We need to call this in the next cycle, otherwise it can cause + // issues on mobile devices on orientation change. It will use the + // height of the previous orientation otherwise. + this.updateSizeDestroy = function() { + window.setTimeout(function() { me.updateSize(); }, 0); + }; OpenLayers.Event.observe(window, 'resize', this.updateSizeDestroy); } From 2843a186020ea5329c485b59d8de514f6b5576f8 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Thu, 16 Aug 2012 16:35:21 +0200 Subject: [PATCH 89/91] Revert "fix issue with orientation changes on mobile devices (tested on Motorola Xoom 2 with Android 3.2.2 in the stock browser)" This reverts commit 39a6d7d8ef42860ff9d726af27715454573fb335. --- lib/OpenLayers/Map.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index ed90015b61..ab2cc1a928 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -588,13 +588,8 @@ OpenLayers.Map = OpenLayers.Class({ // Else updateSize on catching the window's resize // Note that this is ok, as updateSize() does nothing if the // map's size has not actually changed. - var me = this; - // We need to call this in the next cycle, otherwise it can cause - // issues on mobile devices on orientation change. It will use the - // height of the previous orientation otherwise. - this.updateSizeDestroy = function() { - window.setTimeout(function() { me.updateSize(); }, 0); - }; + this.updateSizeDestroy = OpenLayers.Function.bind(this.updateSize, + this); OpenLayers.Event.observe(window, 'resize', this.updateSizeDestroy); } From 3b9ce4ca2dbacb6ff7473d8cea935bce826db771 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Fri, 17 Aug 2012 10:13:04 +0200 Subject: [PATCH 90/91] introduce new property on the Map called autoUpdateSize which lets applications take control of window resizing / device orientation changes if they want to --- lib/OpenLayers/Map.js | 51 ++++++++++++++++++++++++++----------------- tests/Map.html | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 20 deletions(-) diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index ab2cc1a928..3dd31f2632 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -376,6 +376,13 @@ OpenLayers.Map = OpenLayers.Class({ * Default is to fall through. */ fallThrough: true, + + /** + * APIProperty: autoUpdateSize + * {Boolean} Should OpenLayers automatically update the size of the map + * when the resize event is fired. Default is true. + */ + autoUpdateSize: true, /** * Property: panTween @@ -578,20 +585,22 @@ OpenLayers.Map = OpenLayers.Class({ if(this.eventListeners instanceof Object) { this.events.on(this.eventListeners); } - - // Because Mozilla does not support the "resize" event for elements - // other than "window", we need to put a hack here. - if (parseFloat(navigator.appVersion.split("MSIE")[1]) < 9) { - // If IE < 9, register the resize on the div - this.events.register("resize", this, this.updateSize); - } else { - // Else updateSize on catching the window's resize - // Note that this is ok, as updateSize() does nothing if the - // map's size has not actually changed. - this.updateSizeDestroy = OpenLayers.Function.bind(this.updateSize, - this); - OpenLayers.Event.observe(window, 'resize', - this.updateSizeDestroy); + + if (this.autoUpdateSize === true) { + // Because Mozilla does not support the "resize" event for elements + // other than "window", we need to put a hack here. + if (parseFloat(navigator.appVersion.split("MSIE")[1]) < 9) { + // If IE < 9, register the resize on the div + this.events.register("resize", this, this.updateSize); + } else { + // Else updateSize on catching the window's resize + // Note that this is ok, as updateSize() does nothing if the + // map's size has not actually changed. + this.updateSizeDestroy = OpenLayers.Function.bind(this.updateSize, + this); + OpenLayers.Event.observe(window, 'resize', + this.updateSizeDestroy); + } } // only append link stylesheet if the theme property is set @@ -744,12 +753,14 @@ OpenLayers.Map = OpenLayers.Class({ OpenLayers.Event.stopObserving(window, 'unload', this.unloadDestroy); this.unloadDestroy = null; - if (this.updateSizeDestroy) { - OpenLayers.Event.stopObserving(window, 'resize', - this.updateSizeDestroy); - } else { - this.events.unregister("resize", this, this.updateSize); - } + if (this.autoUpdateSize === true) { + if (this.updateSizeDestroy) { + OpenLayers.Event.stopObserving(window, 'resize', + this.updateSizeDestroy); + } else { + this.events.unregister("resize", this, this.updateSize); + } + } this.paddingForPopups = null; diff --git a/tests/Map.html b/tests/Map.html index 6323c249db..73fcbbbc87 100644 --- a/tests/Map.html +++ b/tests/Map.html @@ -2090,6 +2090,48 @@ t.ok(center.equals(new OpenLayers.LonLat(-13.25, 56)), "Center is correct and not equal to maxExtent's center"); } + function test_autoUpdateSize(t) { + t.plan(1); + OpenLayers.Event.unloadCache(); + var resizeListener = false; + var register = OpenLayers.Events.prototype.register; + OpenLayers.Events.prototype.register = function(name, el , func) { + if (name === 'resize') { + resizeListener = true; + } + }; + var map = new OpenLayers.Map({ + events: { + register: function(name, el, func) { + if (name === 'resize') { + resizeListener = true; + } + } + }, + autoUpdateSize: false, + div: 'map', + layers: [ + new OpenLayers.Layer('name', { + isBaseLayer: true, + wrapDateLine: true + }) + ] + }); + map.setCenter(new OpenLayers.LonLat(-1.3, 50.8), 4); + for (var key in OpenLayers.Event.observers) { + var obj = OpenLayers.Event.observers[key]; + for (var i=0, ii=obj.length; i From 7b4cb8e3f5b0b7929614264d1ab3eada072c1994 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Fri, 17 Aug 2012 11:36:03 +0200 Subject: [PATCH 91/91] cleanup and always use window resize as suggested by @tonio --- lib/OpenLayers/Map.js | 31 ++++++++++--------------------- tests/Map.html | 14 -------------- 2 files changed, 10 insertions(+), 35 deletions(-) diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 3dd31f2632..2b85ebe180 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -587,20 +587,13 @@ OpenLayers.Map = OpenLayers.Class({ } if (this.autoUpdateSize === true) { - // Because Mozilla does not support the "resize" event for elements - // other than "window", we need to put a hack here. - if (parseFloat(navigator.appVersion.split("MSIE")[1]) < 9) { - // If IE < 9, register the resize on the div - this.events.register("resize", this, this.updateSize); - } else { - // Else updateSize on catching the window's resize - // Note that this is ok, as updateSize() does nothing if the - // map's size has not actually changed. - this.updateSizeDestroy = OpenLayers.Function.bind(this.updateSize, - this); - OpenLayers.Event.observe(window, 'resize', - this.updateSizeDestroy); - } + // updateSize on catching the window's resize + // Note that this is ok, as updateSize() does nothing if the + // map's size has not actually changed. + this.updateSizeDestroy = OpenLayers.Function.bind(this.updateSize, + this); + OpenLayers.Event.observe(window, 'resize', + this.updateSizeDestroy); } // only append link stylesheet if the theme property is set @@ -753,13 +746,9 @@ OpenLayers.Map = OpenLayers.Class({ OpenLayers.Event.stopObserving(window, 'unload', this.unloadDestroy); this.unloadDestroy = null; - if (this.autoUpdateSize === true) { - if (this.updateSizeDestroy) { - OpenLayers.Event.stopObserving(window, 'resize', - this.updateSizeDestroy); - } else { - this.events.unregister("resize", this, this.updateSize); - } + if (this.updateSizeDestroy) { + OpenLayers.Event.stopObserving(window, 'resize', + this.updateSizeDestroy); } this.paddingForPopups = null; diff --git a/tests/Map.html b/tests/Map.html index 73fcbbbc87..50b7cdf770 100644 --- a/tests/Map.html +++ b/tests/Map.html @@ -2094,20 +2094,7 @@ t.plan(1); OpenLayers.Event.unloadCache(); var resizeListener = false; - var register = OpenLayers.Events.prototype.register; - OpenLayers.Events.prototype.register = function(name, el , func) { - if (name === 'resize') { - resizeListener = true; - } - }; var map = new OpenLayers.Map({ - events: { - register: function(name, el, func) { - if (name === 'resize') { - resizeListener = true; - } - } - }, autoUpdateSize: false, div: 'map', layers: [ @@ -2129,7 +2116,6 @@ } t.eq(resizeListener, map.autoUpdateSize, "resize listener not registered when autoUpdateSize is false"); map.destroy(); - OpenLayers.Events.prototype.register = register; }