diff --git a/apidoc_config/Menu.txt b/apidoc_config/Menu.txt index 003c4e43fd..93d68c2a33 100644 --- a/apidoc_config/Menu.txt +++ b/apidoc_config/Menu.txt @@ -280,7 +280,6 @@ Group: OpenLayers { } # Group: Handler File: Icon (no auto-title, OpenLayers/Icon.js) - File: Kinetic (no auto-title, OpenLayers/Kinetic.js) Group: Lang { diff --git a/examples/mobile-base.js b/examples/mobile-base.js index f320581787..5e123cc3b9 100644 --- a/examples/mobile-base.js +++ b/examples/mobile-base.js @@ -15,7 +15,7 @@ var init = function (onSelectFeatureFunction) { styleMap: new OpenLayers.StyleMap({ externalGraphic: "img/mobile-loc.png", graphicOpacity: 1.0, - graphicWith: 16, + graphicWidth: 16, graphicHeight: 26, graphicYOffset: -26 }) diff --git a/lib/OpenLayers/Control/Geolocate.js b/lib/OpenLayers/Control/Geolocate.js index 2daf898fb1..28b93bb062 100644 --- a/lib/OpenLayers/Control/Geolocate.js +++ b/lib/OpenLayers/Control/Geolocate.js @@ -24,7 +24,10 @@ OpenLayers.Control.Geolocate = OpenLayers.Class(OpenLayers.Control, { /** * Supported event types: - * - *locationupdated* Triggered when browser return a new position + * - *locationupdated* Triggered when browser return a new position. Listeners will + * receive an object with a 'position' property which is the browser.geolocation.position + * native object, as well as a 'point' property which is the location transformed in the + * current map projection. * - *locationfailed* Triggered when geolocation has failed * - *locationuncapable* Triggered when control is activated on a browser * which doesn't support geolocation diff --git a/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js b/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js index 8ad98a25aa..9cb6427ff9 100644 --- a/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js +++ b/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js @@ -262,7 +262,9 @@ OpenLayers.Format.CSWGetRecords.v2_0_2 = OpenLayers.Class(OpenLayers.Format.XML, dc_element[attrs[i].name] = attrs[i].nodeValue; } dc_element.value = this.getChildValue(node); - obj[name].push(dc_element); + if (dc_element.value != "") { + obj[name].push(dc_element); + } } }, "dct": { diff --git a/lib/OpenLayers/Geometry/LinearRing.js b/lib/OpenLayers/Geometry/LinearRing.js index c8b960915c..4c5450e82d 100644 --- a/lib/OpenLayers/Geometry/LinearRing.js +++ b/lib/OpenLayers/Geometry/LinearRing.js @@ -294,7 +294,7 @@ OpenLayers.Geometry.LinearRing = OpenLayers.Class( var px = approx(point.x, digs); var py = approx(point.y, digs); function getX(y, x1, y1, x2, y2) { - return (((x1 - x2) * y) + ((x2 * y1) - (x1 * y2))) / (y1 - y2); + return (y - y2) * ((x2 - x1) / (y2 - y1)) + x2; } var numSeg = this.components.length - 1; var start, end, x1, y1, x2, y2, cx, cy; diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js index db817af4c7..fdc4edaa34 100644 --- a/lib/OpenLayers/Layer.js +++ b/lib/OpenLayers/Layer.js @@ -265,6 +265,16 @@ OpenLayers.Layer = OpenLayers.Class({ * {Float} */ minResolution: null, + + /** + * Property: resolution + * {Float} Current resolution that the layer is drawn in. This is + * used to determine whether the zoom has changed when calling + * from . Subclasses may set this.resolution to + * null prior to calling redraw to force passing zoomChanged + * true to moveTo. + */ + resolution: null, /** * APIProperty: numZoomLevels @@ -552,7 +562,8 @@ OpenLayers.Layer = OpenLayers.Class({ var extent = this.getExtent(); if (extent && this.inRange && this.visibility) { - var zoomChanged = true; + zoomChanged = this.resolution == null || + this.resolution !== this.map.getResolution(); this.moveTo(extent, zoomChanged, false); this.events.triggerEvent("moveend", {"zoomChanged": zoomChanged}); @@ -577,6 +588,7 @@ OpenLayers.Layer = OpenLayers.Class({ display = display && this.inRange; } this.display(display); + this.resolution = this.map.getResolution(); }, /** @@ -632,6 +644,8 @@ OpenLayers.Layer = OpenLayers.Class({ // deal with gutters this.setTileSize(); + + this.resolution = null; } }, diff --git a/lib/OpenLayers/Layer/HTTPRequest.js b/lib/OpenLayers/Layer/HTTPRequest.js index 1a76e1e23b..7855cb6b03 100644 --- a/lib/OpenLayers/Layer/HTTPRequest.js +++ b/lib/OpenLayers/Layer/HTTPRequest.js @@ -120,6 +120,7 @@ OpenLayers.Layer.HTTPRequest = OpenLayers.Class(OpenLayers.Layer, { */ mergeNewParams:function(newParams) { this.params = OpenLayers.Util.extend(this.params, newParams); + this.resolution = null; var ret = this.redraw(); if(this.map != null) { this.map.events.triggerEvent("changelayer", { @@ -144,7 +145,7 @@ OpenLayers.Layer.HTTPRequest = OpenLayers.Class(OpenLayers.Layer, { if (force) { return this.mergeNewParams({"_olSalt": Math.random()}); } else { - return OpenLayers.Layer.prototype.redraw.apply(this, []); + return OpenLayers.Layer.prototype.redraw.call(this); } }, diff --git a/lib/OpenLayers/Protocol/HTTP.js b/lib/OpenLayers/Protocol/HTTP.js index 37768fbac0..edcb3ed6fa 100644 --- a/lib/OpenLayers/Protocol/HTTP.js +++ b/lib/OpenLayers/Protocol/HTTP.js @@ -9,8 +9,8 @@ */ /** - * TODO: remove this dependency in 3.0 - * @requires OpenLayers/Format/QueryStringFilter.js + * if application uses the query string, for example, for BBOX parameters, + * OpenLayers/Format/QueryStringFilter.js should be included in the build config file */ /** diff --git a/lib/OpenLayers/Protocol/Script.js b/lib/OpenLayers/Protocol/Script.js index b53b8bed02..49e332b7f0 100644 --- a/lib/OpenLayers/Protocol/Script.js +++ b/lib/OpenLayers/Protocol/Script.js @@ -9,6 +9,11 @@ * @requires OpenLayers/Format/GeoJSON.js */ +/** + * if application uses the query string, for example, for BBOX parameters, + * OpenLayers/Format/QueryStringFilter.js should be included in the build config file + */ + /** * Class: OpenLayers.Protocol.Script * A basic Script protocol for vector layers. Create a new instance with the diff --git a/notes/2.12.md b/notes/2.12.md index 6fa1f42310..7013846924 100644 --- a/notes/2.12.md +++ b/notes/2.12.md @@ -54,6 +54,10 @@ Without the WKT format included (by default), the `OpenLayers.Geometry::toString `Layer.OSM` is now defined in its own script file, namely `OpenLayers/Layer/OSM.js`. So people using `Layer.OSM` should now include `OpenLayers/Layer/OSM.js`, as opposed to `OpenLayers/Layer/XYZ.js`, in their OpenLayers builds. (See https://github.com/openlayers/openlayers/issues/138) +## QueryStringFilter + +`OpenLayers.Protocol.HTTP` no longer requires `OpenLayers.Format.QueryStringFilter`. It you need this, make sure it is included in your build config file. + ## Deprecated Components A number of properties, methods, and constructors have been marked as deprecated for multiple releases in the 2.x series. For the 2.12 release this deprecated functionality has been moved to a separate deprecated.js file. If you use any of the constructors or methods below, you will have to explicitly include the deprecated.js file in your build (or add it in a separate ` diff --git a/tests/Layer.html b/tests/Layer.html index eabd233aee..d3b5072f4c 100644 --- a/tests/Layer.html +++ b/tests/Layer.html @@ -672,19 +672,82 @@ // test that the moveend event was triggered t.ok(log.event, "an event was logged"); t.eq(log.event.type, "moveend", "moveend was triggered"); - t.eq(log.event.zoomChanged, true, "event says zoomChanged true - poor name"); + t.eq(log.event.zoomChanged, false, "event says zoomChanged false"); layer.moveTo = function(bounds, zoomChanged, dragging) { var extent = layer.map.getExtent(); t.ok(bounds.equals(extent), "redraw calls moveTo with the map extent"); - t.ok(zoomChanged, - "redraw calls moveTo with zoomChanged true"); + t.ok(!zoomChanged, + "redraw calls moveTo with zoomChanged false"); t.ok(!dragging, "redraw calls moveTo with dragging false"); } layer.redraw(); } + + // This function includes integration tests to verify that the + // layer's moveTo function is called with the expected value + // for zoomChanged + function test_moveTo_zoomChanged(t) { + t.plan(6); + + var log = {}; + var map = new OpenLayers.Map('map'); + + var l1 = new OpenLayers.Layer('l1', {isBaseLayer: true}); + l1.moveTo = function(bounds, zoomChanged, dragging) { + log.moveTo = {zoomChanged: zoomChanged}; + OpenLayers.Layer.prototype.moveTo.apply(this, arguments); + }; + + map.addLayer(l1); + map.zoomToMaxExtent(); + + log = {}; + l1.redraw(); + t.eq(log.moveTo.zoomChanged, false, + "[a] redraw calls moveTo with zoomChanged false"); + + log = {}; + l1.resolution = null; + l1.redraw(); + t.eq(log.moveTo.zoomChanged, true, + "[b] redraw calls moveTo with zoomChanged true"); + + l1.setVisibility(false); + log = {}; + l1.setVisibility(true); + t.eq(log.moveTo.zoomChanged, false, + "[c] redraw calls moveTo with zoomChanged false"); + + l1.setVisibility(false); + map.zoomIn(); + log = {}; + l1.setVisibility(true); + t.eq(log.moveTo.zoomChanged, true, + "[d] redraw calls moveTo with zoomChanged true"); + + l1.moveTo = OpenLayers.Layer.prototype.moveTo; + + var l2 = new OpenLayers.Layer('l2'); + l2.moveTo = function(bounds, zoomChanged, dragging) { + log.moveTo = {zoomChanged: zoomChanged}; + OpenLayers.Layer.prototype.moveTo.apply(this, arguments); + }; + log = {}; + map.addLayer(l2); + t.eq(log.moveTo.zoomChanged, true, + "[e] redraw calls moveTo with zoomChanged true"); + + map.removeLayer(l2); + log = {}; + map.addLayer(l2); + t.eq(log.moveTo.zoomChanged, true, + "[f] redraw calls moveTo with zoomChanged true"); + + map.destroy(); + } function test_layer_setIsBaseLayer(t) { t.plan(2); diff --git a/tests/Layer/HTTPRequest.html b/tests/Layer/HTTPRequest.html index 02311564f1..6539b12bef 100644 --- a/tests/Layer/HTTPRequest.html +++ b/tests/Layer/HTTPRequest.html @@ -65,7 +65,7 @@ } function test_Layer_HTTPRequest_mergeNewParams (t) { - t.plan( 8 ); + t.plan( 9 ); var map = new OpenLayers.Map('map'); layer = new OpenLayers.Layer.HTTPRequest(name, url, params, options); @@ -97,7 +97,9 @@ layer.redraw = function() { t.ok(true, "layer.mergeNewParams calls layer.redraw"); - } + t.ok(layer.resolution === null, "layer.mergeNewParams sets resolution to null"); + }; + layer.resolution = 'fake'; layer.mergeNewParams(); } diff --git a/tests/Popup.html b/tests/Popup.html index 10245a0199..2d6a90b98e 100644 --- a/tests/Popup.html +++ b/tests/Popup.html @@ -191,13 +191,14 @@ //closeOnMove var checkMapEvent = function(map, popup) { var startListeners = map.events.listeners['movestart']; - for(var i=0; i < startListeners.length; i++) { - var listener = startListeners[i]; - - if ((listener.obj == popup) && (listener.func == popup.hide)) { - return true; + if (startListeners) { + for (var i = 0; i < startListeners.length; i++) { + var listener = startListeners[i]; + if ((listener.obj == popup) && (listener.func == popup.hide)) { + return true; + } } - } + } return false; }; var registered = checkMapEvent(map1, popup); diff --git a/tests/Tile/Image.html b/tests/Tile/Image.html index 0f71c542dd..f350b5c059 100644 --- a/tests/Tile/Image.html +++ b/tests/Tile/Image.html @@ -342,6 +342,38 @@ t.ok(tile.imgDiv == null, "image reference removed from tile"); map.destroy(); } + + // test for https://github.com/openlayers/openlayers/pull/36 + // (more an integration test than a unit test) + function test_olImageLoadError(t) { + t.plan(2); + + var map = new OpenLayers.Map('map'); + var layer = new OpenLayers.Layer.WMS("invalid", "", {layers: 'basic'}); + map.addLayer(layer); + + var size = new OpenLayers.Size(5, 6); + var position = new OpenLayers.Pixel(20, 30); + var bounds = new OpenLayers.Bounds(1, 2, 3, 4); + + var tile = new OpenLayers.Tile.Image(layer, position, bounds, null, size); + tile.draw(); + + t.delay_call(0.1, function() { + + // check initial state + t.ok(OpenLayers.Element.hasClass(tile.imgDiv, 'olImageLoadError'), + 'tile image has the olImageLoadError class (init state)'); + + layer.setVisibility(false); + layer.setVisibility(true); + + t.ok(OpenLayers.Element.hasClass(tile.imgDiv, 'olImageLoadError'), + 'tile image still has the olImageLoadError class'); + + map.destroy(); + }); + }