diff --git a/examples/graphic-name.js b/examples/graphic-name.js index 9349ed28b6..654a4c997d 100644 --- a/examples/graphic-name.js +++ b/examples/graphic-name.js @@ -5,6 +5,10 @@ OpenLayers.Renderer.symbol.church = [4, 0, 6, 0, 6, 4, 10, 4, 10, 6, 6, 6, 6, 14 var map; function init(){ + // allow testing of specific renderers via "?renderer=Canvas", etc + var renderer = OpenLayers.Util.getParameters(window.location.href).renderer; + renderer = (renderer) ? [renderer] : OpenLayers.Layer.Vector.prototype.renderers; + map = new OpenLayers.Map('map', { controls: [] }); @@ -46,7 +50,8 @@ function init(){ // Create a vector layer and give it your style map. var layer = new OpenLayers.Layer.Vector("Graphics", { styleMap: styles, - isBaseLayer: true + isBaseLayer: true, + renderers: renderer }); layer.addFeatures(features); map.addLayer(layer); diff --git a/examples/transform-feature.html b/examples/transform-feature.html index d768c106a6..a0c5645de2 100644 --- a/examples/transform-feature.html +++ b/examples/transform-feature.html @@ -14,30 +14,6 @@ function init(){ map = new OpenLayers.Map('map', {allOverlays: true}); - // context for appropriate scale/resize cursors - var cursors = ["sw-resize", "s-resize", "se-resize", - "e-resize", "ne-resize", "n-resize", "nw-resize", "w-resize"]; - var context = { - getCursor: function(feature){ - var i = OpenLayers.Util.indexOf(control.handles, feature); - var cursor = "inherit"; - if(i !== -1) { - i = (i + 8 + Math.round(control.rotation / 90) * 2) % 8; - cursor = cursors[i]; - } - return cursor; - } - }; - - // a nice style for the transformation box - var style = new OpenLayers.Style({ - cursor: "${getCursor}", - pointRadius: 5, - fillColor: "white", - fillOpacity: 1, - strokeColor: "black" - }, {context: context}); - // allow testing of specific renderers via "?renderer=Canvas", etc var renderer = OpenLayers.Util.getParameters(window.location.href).renderer; renderer = (renderer) ? [renderer] : OpenLayers.Layer.Vector.prototype.renderers; @@ -45,7 +21,36 @@ // the layer that we want to transform features on var vectorLayer = new OpenLayers.Layer.Vector("Simple Geometry", { styleMap: new OpenLayers.StyleMap({ - "transform": style + // a nice style for the transformation box + "transform": new OpenLayers.Style({ + display: "${getDisplay}", + cursor: "${role}", + pointRadius: 5, + fillColor: "white", + fillOpacity: 1, + strokeColor: "black" + }, { + context: { + getDisplay: function(feature) { + // hide the resize handle at the south-east corner + return feature.attributes.role === "se-resize" ? "none" : ""; + } + } + }), + "rotate": new OpenLayers.Style({ + display: "${getDisplay}", + pointRadius: 10, + fillColor: "#ddd", + fillOpacity: 1, + strokeColor: "black" + }, { + context: { + getDisplay: function(feature) { + // only display the rotate handle at the south-east corner + return feature.attributes.role === "se-rotate" ? "" : "none"; + } + } + }) }), renderers: renderer }); @@ -53,7 +58,8 @@ // create the TransformFeature control, using the renderIntent // from above control = new OpenLayers.Control.TransformFeature(vectorLayer, { - renderIntent: "transform" + renderIntent: "transform", + rotationHandleSymbolizer: "rotate" }); map.addControl(control); @@ -101,13 +107,15 @@

This example shows transformation of vector features with a tranformation box. Grab one of the handles to resize the feature. - Holding the SHIFT key will preserve the aspect ratio. Position the - mouse right outside one of the corner handles to rotate the feature, - and hold the SHIFT key to only rotate in 45° increments.

-

In this example, the transformation box has been set on the left + Holding the SHIFT key will preserve the aspect ratio. Use the gray + handle to rotate the feature and hold the SHIFT key to only rotate + in 45° increments. +

+

In this example, the transformation box has been set on the left feature, with a rotation preset of 45°. Clicking on the right feature will set it for transformation, starting with an unrotated box. - Dragging a feature or the box edges will move it around.

+ Dragging a feature or the box edges will move it around. +

diff --git a/lib/OpenLayers/BaseTypes/Bounds.js b/lib/OpenLayers/BaseTypes/Bounds.js index 46b992961d..5a527ca02a 100644 --- a/lib/OpenLayers/BaseTypes/Bounds.js +++ b/lib/OpenLayers/BaseTypes/Bounds.js @@ -359,7 +359,8 @@ OpenLayers.Bounds = OpenLayers.Class({ * APIMethod: containsLonLat * * Parameters: - * ll - {} + * ll - {|Object} OpenLayers.LonLat or an + * object with a 'lon' and 'lat' properties. * options - {Object} Optional parameters * * Acceptable options: @@ -382,13 +383,12 @@ OpenLayers.Bounds = OpenLayers.Class({ worldBounds = options.worldBounds; if (worldBounds && !contains) { var worldWidth = worldBounds.getWidth(); - ll = ll.clone(); var worldCenterX = (worldBounds.left + worldBounds.right) / 2; var worldsAway = Math.round((ll.lon - worldCenterX) / worldWidth); - ll.lon -= (worldsAway * worldWidth); - contains = this.containsLonLat( - ll, {inclusive: options.inclusive} - ); + contains = this.containsLonLat({ + lon: ll.lon - worldsAway * worldWidth, + lat: ll.lat + }, {inclusive: options.inclusive}); } return contains; }, diff --git a/lib/OpenLayers/Control/KeyboardDefaults.js b/lib/OpenLayers/Control/KeyboardDefaults.js index a015a9ae16..f3505353f0 100644 --- a/lib/OpenLayers/Control/KeyboardDefaults.js +++ b/lib/OpenLayers/Control/KeyboardDefaults.js @@ -62,6 +62,7 @@ OpenLayers.Control.KeyboardDefaults = OpenLayers.Class(OpenLayers.Control, { * evt - {Event} */ defaultKeyPress: function (evt) { + var size; switch(evt.keyCode) { case OpenLayers.Event.KEY_LEFT: this.map.pan(-this.slideFactor, 0); @@ -77,19 +78,19 @@ OpenLayers.Control.KeyboardDefaults = OpenLayers.Class(OpenLayers.Control, { break; case 33: // Page Up. Same in all browsers. - var size = this.map.getSize(); + size = this.map.getSize(); this.map.pan(0, -0.75*size.h); break; case 34: // Page Down. Same in all browsers. - var size = this.map.getSize(); + size = this.map.getSize(); this.map.pan(0, 0.75*size.h); break; case 35: // End. Same in all browsers. - var size = this.map.getSize(); + size = this.map.getSize(); this.map.pan(0.75*size.w, 0); break; case 36: // Home. Same in all browsers. - var size = this.map.getSize(); + size = this.map.getSize(); this.map.pan(-0.75*size.w, 0); break; diff --git a/lib/OpenLayers/Control/OverviewMap.js b/lib/OpenLayers/Control/OverviewMap.js index 67bba68886..29fefeb5b2 100644 --- a/lib/OpenLayers/Control/OverviewMap.js +++ b/lib/OpenLayers/Control/OverviewMap.js @@ -628,12 +628,14 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, { * translated into pixel bounds for the overview map */ getRectBoundsFromMapBounds: function(lonLatBounds) { - var leftBottomLonLat = new OpenLayers.LonLat(lonLatBounds.left, - lonLatBounds.bottom); - var rightTopLonLat = new OpenLayers.LonLat(lonLatBounds.right, - lonLatBounds.top); - var leftBottomPx = this.getOverviewPxFromLonLat(leftBottomLonLat); - var rightTopPx = this.getOverviewPxFromLonLat(rightTopLonLat); + var leftBottomPx = this.getOverviewPxFromLonLat({ + lon: lonLatBounds.left, + lat: lonLatBounds.bottom + }); + var rightTopPx = this.getOverviewPxFromLonLat({ + lon: lonLatBounds.right, + lat: lonLatBounds.top + }); var bounds = null; if (leftBottomPx && rightTopPx) { bounds = new OpenLayers.Bounds(leftBottomPx.x, leftBottomPx.y, @@ -699,7 +701,8 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, { * Get a pixel location from a map location * * Parameters: - * lonlat - {} + * lonlat - {|Object} OpenLayers.LonLat or an + * object with a 'lon' and 'lat' properties. * * Returns: * {Object} Location which is the passed-in OpenLayers.LonLat, diff --git a/lib/OpenLayers/Control/TransformFeature.js b/lib/OpenLayers/Control/TransformFeature.js index e0fa7c3b5a..2b719a4450 100644 --- a/lib/OpenLayers/Control/TransformFeature.js +++ b/lib/OpenLayers/Control/TransformFeature.js @@ -232,9 +232,6 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, { this.dragControl.deactivate(); deactivated = true; } - if (deactivated) { - this.unsetFeature(); - } return deactivated; }, @@ -335,7 +332,7 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, { var control = this; this.center = new OpenLayers.Geometry.Point(0, 0); - var box = new OpenLayers.Feature.Vector( + this.box = new OpenLayers.Feature.Vector( new OpenLayers.Geometry.LineString([ new OpenLayers.Geometry.Point(-1, -1), new OpenLayers.Geometry.Point(0, -1), @@ -351,7 +348,7 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, { ); // Override for box move - make sure that the center gets updated - box.geometry.move = function(x, y) { + this.box.geometry.move = function(x, y) { control._moving = true; OpenLayers.Geometry.LineString.prototype.move.apply(this, arguments); control.center.move(x, y); @@ -468,14 +465,17 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, { var handles = new Array(8); var rotationHandles = new Array(4); var geom, handle, rotationHandle; + var positions = ["sw", "s", "se", "e", "ne", "n", "nw", "w"]; for(var i=0; i<8; ++i) { - geom = box.geometry.components[i]; - handle = new OpenLayers.Feature.Vector(geom.clone(), null, - typeof this.renderIntent == "string" ? null : + geom = this.box.geometry.components[i]; + handle = new OpenLayers.Feature.Vector(geom.clone(), { + role: positions[i] + "-resize" + }, typeof this.renderIntent == "string" ? null : this.renderIntent); if(i % 2 == 0) { - rotationHandle = new OpenLayers.Feature.Vector(geom.clone(), - null, typeof this.rotationHandleSymbolizer == "string" ? + rotationHandle = new OpenLayers.Feature.Vector(geom.clone(), { + role: positions[i] + "-rotate" + }, typeof this.rotationHandleSymbolizer == "string" ? null : this.rotationHandleSymbolizer); rotationHandle.geometry.move = rotationHandleMoveFn; geom._rotationHandle = rotationHandle; @@ -489,7 +489,6 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, { handles[i] = handle; } - this.box = box; this.rotationHandles = rotationHandles; this.handles = handles; }, @@ -514,7 +513,6 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, { onDrag: function(feature, pixel) { if(feature === control.box) { control.transformFeature({center: control.center}); - control.drawHandles(); } }, // set a new feature @@ -600,10 +598,16 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, { geom._rotationHandle && geom._rotationHandle.destroy(); geom._rotationHandle = null; } + this.center = null; + this.feature = null; + this.handles = null; + this.rotationHandleSymbolizer = null; + this.rotationHandles = null; this.box.destroy(); this.box = null; this.layer = null; this.dragControl.destroy(); + this.dragControl = null; OpenLayers.Control.prototype.destroy.apply(this, arguments); }, diff --git a/lib/OpenLayers/Events/buttonclick.js b/lib/OpenLayers/Events/buttonclick.js index 1fddfb705e..1412833920 100644 --- a/lib/OpenLayers/Events/buttonclick.js +++ b/lib/OpenLayers/Events/buttonclick.js @@ -25,7 +25,7 @@ OpenLayers.Events.buttonclick = OpenLayers.Class({ /** - * APIProperty: target + * Property: target * {} The events instance that the buttonclick event will * be triggered on. */ @@ -141,4 +141,4 @@ OpenLayers.Events.buttonclick = OpenLayers.Class({ return propagate; } -}); \ No newline at end of file +}); diff --git a/lib/OpenLayers/Feature/Vector.js b/lib/OpenLayers/Feature/Vector.js index 75dd5ff20d..27928a2b47 100644 --- a/lib/OpenLayers/Feature/Vector.js +++ b/lib/OpenLayers/Feature/Vector.js @@ -267,7 +267,8 @@ OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, { * Determins whether the feature intersects with the specified location. * * Parameters: - * lonlat - {} + * lonlat - {|Object} OpenLayers.LonLat or an + * object with a 'lon' and 'lat' properties. * toleranceLon - {float} Optional tolerance in Geometric Coords * toleranceLat - {float} Optional tolerance in Geographic Coords * diff --git a/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js b/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js index b1fece8112..4a5aa18491 100644 --- a/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js +++ b/lib/OpenLayers/Format/CSWGetRecords/v2_0_2.js @@ -255,7 +255,7 @@ OpenLayers.Format.CSWGetRecords.v2_0_2 = OpenLayers.Class(OpenLayers.Format.XML, "*": function(node, obj) { var name = node.localName || node.nodeName.split(":").pop(); if (!(OpenLayers.Util.isArray(obj[name]))) { - obj[name] = new Array(); + obj[name] = []; } var dc_element = {}; var attrs = node.attributes; @@ -273,7 +273,7 @@ OpenLayers.Format.CSWGetRecords.v2_0_2 = OpenLayers.Class(OpenLayers.Format.XML, "*": function(node, obj) { var name = node.localName || node.nodeName.split(":").pop(); if (!(OpenLayers.Util.isArray(obj[name]))) { - obj[name] = new Array(); + obj[name] = []; } obj[name].push(this.getChildValue(node)); } diff --git a/lib/OpenLayers/Format/XLS/v1.js b/lib/OpenLayers/Format/XLS/v1.js index 8f7c31b095..aa3fda7068 100644 --- a/lib/OpenLayers/Format/XLS/v1.js +++ b/lib/OpenLayers/Format/XLS/v1.js @@ -228,7 +228,7 @@ OpenLayers.Format.XLS.v1 = OpenLayers.Class(OpenLayers.Format.XML, { } }); if (address.freeFormAddress) { - this.writeNode("freeFormAddess", address.freeFormAddress, node); + this.writeNode("freeFormAddress", address.freeFormAddress, node); } else { if (address.street) { this.writeNode("StreetAddress", address, node); diff --git a/lib/OpenLayers/Geometry.js b/lib/OpenLayers/Geometry.js index 888f73b83e..f199e3fa35 100644 --- a/lib/OpenLayers/Geometry.js +++ b/lib/OpenLayers/Geometry.js @@ -176,7 +176,8 @@ OpenLayers.Geometry = OpenLayers.Class({ * geometry. * * Parameters: - * lonlat - {} + * lonlat - {|Object} OpenLayers.LonLat or an + * object with a 'lon' and 'lat' properties. * toleranceLon - {float} Optional tolerance in Geometric Coords * toleranceLat - {float} Optional tolerance in Geographic Coords * diff --git a/lib/OpenLayers/Layer/ArcIMS.js b/lib/OpenLayers/Layer/ArcIMS.js index 860cd8d770..eb7dbc983c 100644 --- a/lib/OpenLayers/Layer/ArcIMS.js +++ b/lib/OpenLayers/Layer/ArcIMS.js @@ -205,12 +205,10 @@ OpenLayers.Layer.ArcIMS = OpenLayers.Class(OpenLayers.Layer.Grid, { * Parameters: * bounds - {} A bounds representing the bbox for the * request. - * scope - {Object} The scope of the callback method. - * prop - {String} The name of the property in the scoped object to - * recieve the image url. * callback - {Function} Function to call when image url is retrieved. + * scope - {Object} The scope of the callback method. */ - getURLasync: function(bounds, scope, prop, callback) { + getURLasync: function(bounds, callback, scope) { bounds = this.adjustBounds(bounds); // create an arcxml request to generate the image @@ -239,11 +237,7 @@ OpenLayers.Layer.ArcIMS = OpenLayers.Class(OpenLayers.Layer.Grid, { var axlResp = new OpenLayers.Format.ArcXML(); var arcxml = axlResp.read(doc); - scope[prop] = this.getUrlOrImage(arcxml.image.output); - - // call the callback function to recieve the updated property on the - // scoped object - callback.apply(scope); + callback.call(scope, this.getUrlOrImage(arcxml.image.output)); }, scope: this }); diff --git a/lib/OpenLayers/Layer/Boxes.js b/lib/OpenLayers/Layer/Boxes.js index 91c3d49cad..481b742542 100644 --- a/lib/OpenLayers/Layer/Boxes.js +++ b/lib/OpenLayers/Layer/Boxes.js @@ -25,9 +25,6 @@ OpenLayers.Layer.Boxes = OpenLayers.Class(OpenLayers.Layer.Markers, { * name - {String} * options - {Object} Hashtable of extra options to tag onto the layer */ - initialize: function (name, options) { - OpenLayers.Layer.Markers.prototype.initialize.apply(this, arguments); - }, /** * Method: drawMarker diff --git a/lib/OpenLayers/Layer/FixedZoomLevels.js b/lib/OpenLayers/Layer/FixedZoomLevels.js index 47ad10e0d3..ec75499e5f 100644 --- a/lib/OpenLayers/Layer/FixedZoomLevels.js +++ b/lib/OpenLayers/Layer/FixedZoomLevels.js @@ -77,7 +77,7 @@ OpenLayers.Layer.FixedZoomLevels = OpenLayers.Class({ */ initResolutions: function() { - var props = new Array('minZoomLevel', 'maxZoomLevel', 'numZoomLevels'); + var props = ['minZoomLevel', 'maxZoomLevel', 'numZoomLevels']; for(var i=0, len=props.length; i} - * origin - {} + * bounds - {|Object} OpenLayers.Bounds or an + * object with a 'left' and 'top' properties. + * origin - {|Object} OpenLayers.LonLat or an + * object with a 'lon' and 'lat' properties. * resolution - {Number} * * Returns: @@ -686,8 +688,6 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { * tileoffsetlat, tileoffsetx, tileoffsety */ calculateGridLayout: function(bounds, origin, resolution) { - bounds = bounds.clone(); - var tilelon = resolution * this.tileSize.w; var tilelat = resolution * this.tileSize.h; diff --git a/lib/OpenLayers/Layer/MapServer.js b/lib/OpenLayers/Layer/MapServer.js index 544c716a8a..61e9930ab9 100644 --- a/lib/OpenLayers/Layer/MapServer.js +++ b/lib/OpenLayers/Layer/MapServer.js @@ -39,9 +39,7 @@ OpenLayers.Layer.MapServer = OpenLayers.Class(OpenLayers.Layer.Grid, { * options - {Object} Hashtable of extra options to tag onto the layer */ initialize: function(name, url, params, options) { - var newArguments = []; - newArguments.push(name, url, params, options); - OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); + OpenLayers.Layer.Grid.prototype.initialize.apply(this, arguments); this.params = OpenLayers.Util.applyDefaults( this.params, this.DEFAULT_PARAMS diff --git a/lib/OpenLayers/Layer/PointTrack.js b/lib/OpenLayers/Layer/PointTrack.js index 2350415454..5a9dbf2230 100644 --- a/lib/OpenLayers/Layer/PointTrack.js +++ b/lib/OpenLayers/Layer/PointTrack.js @@ -44,9 +44,6 @@ OpenLayers.Layer.PointTrack = OpenLayers.Class(OpenLayers.Layer.Vector, { * options - {Object} Optional object with properties to tag onto the * instance. */ - initialize: function(name, options) { - OpenLayers.Layer.Vector.prototype.initialize.apply(this, arguments); - }, /** * APIMethod: addNodes diff --git a/lib/OpenLayers/Layer/Text.js b/lib/OpenLayers/Layer/Text.js index 9f8cb78cf8..19131a4f9c 100644 --- a/lib/OpenLayers/Layer/Text.js +++ b/lib/OpenLayers/Layer/Text.js @@ -80,7 +80,7 @@ OpenLayers.Layer.Text = OpenLayers.Class(OpenLayers.Layer.Markers, { */ initialize: function(name, options) { OpenLayers.Layer.Markers.prototype.initialize.apply(this, arguments); - this.features = new Array(); + this.features = []; }, /** diff --git a/lib/OpenLayers/Layer/Zoomify.js b/lib/OpenLayers/Layer/Zoomify.js index 2822f67fce..82e3838365 100644 --- a/lib/OpenLayers/Layer/Zoomify.js +++ b/lib/OpenLayers/Layer/Zoomify.js @@ -21,12 +21,6 @@ */ OpenLayers.Layer.Zoomify = OpenLayers.Class(OpenLayers.Layer.Grid, { - /** - * Property: url - * {String} URL for root directory with TileGroupX subdirectories. - */ - url: null, - /** * Property: size * {} The Zoomify image size in pixels. diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index d24bee2882..b8e976851c 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -1161,6 +1161,11 @@ OpenLayers.Map = OpenLayers.Class({ if(!this.allOverlays || this.baseLayer.visibility) { this.baseLayer.setVisibility(true); + // Layer may previously have been visible but not in range. + // In this case we need to redraw it to make it visible. + if (this.baseLayer.inRange === false) { + this.baseLayer.redraw(); + } } // recenter the map diff --git a/lib/OpenLayers/Tile.js b/lib/OpenLayers/Tile.js index 81f6cb4e54..d4a40bb317 100644 --- a/lib/OpenLayers/Tile.js +++ b/lib/OpenLayers/Tile.js @@ -38,6 +38,30 @@ OpenLayers.Tile = OpenLayers.Class({ */ events: null, + /** + * APIProperty: eventListeners + * {Object} If set as an option at construction, the eventListeners + * object will be registered with . Object + * structure must be a listeners object as shown in the example for + * the events.on method. + * + * This options can be set in the ``tileOptions`` option from + * . For example, to be notified of the + * ``loadend`` event of each tiles: + * (code) + * new OpenLayers.Layer.OSM('osm', 'http://tile.openstreetmap.org/${z}/${x}/${y}.png', { + * tileOptions: { + * eventListeners: { + * 'loadend': function(evt) { + * // do something on loadend + * } + * } + * } + * }); + * (end) + */ + eventListeners: null, + /** * Property: id * {String} null @@ -109,10 +133,13 @@ OpenLayers.Tile = OpenLayers.Class({ //give the tile a unique id based on its BBOX. this.id = OpenLayers.Util.createUniqueID("Tile_"); - - this.events = new OpenLayers.Events(this); OpenLayers.Util.extend(this, options); + + this.events = new OpenLayers.Events(this); + if (this.eventListeners instanceof Object) { + this.events.on(this.eventListeners); + } }, /** @@ -139,7 +166,11 @@ OpenLayers.Tile = OpenLayers.Class({ this.size = null; this.position = null; + if (this.eventListeners) { + this.events.un(this.eventListeners); + } this.events.destroy(); + this.eventListeners = null; this.events = null; }, diff --git a/lib/OpenLayers/Tile/Image.js b/lib/OpenLayers/Tile/Image.js index d863d7dece..23a7c9668a 100644 --- a/lib/OpenLayers/Tile/Image.js +++ b/lib/OpenLayers/Tile/Image.js @@ -168,15 +168,14 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, { this.layer.div.appendChild(this.getTile()); if (this.layer.async) { // Asynchronous image requests call the asynchronous getURL method - // on the layer to fetch an image that covers 'this.bounds', in the scope of - // 'this', setting the 'url' property of the layer itself, and running - // the callback 'initImage' when the image request returns. - var myId = this.asyncRequestId = (this.asyncRequestId || 0) + 1; - this.layer.getURLasync(this.bounds, this, "url", function() { - if (myId == this.asyncRequestId) { + // on the layer to fetch an image that covers 'this.bounds'. + var id = this.asyncRequestId = (this.asyncRequestId || 0) + 1; + this.layer.getURLasync(this.bounds, function(url) { + if (id == this.asyncRequestId) { + this.url = url; this.initImage(); } - }); + }, this); } else { // synchronous image requests get the url immediately. this.url = this.layer.getURL(this.bounds); diff --git a/notes/2.12.md b/notes/2.12.md index ee5ae8843c..a02c465a7a 100644 --- a/notes/2.12.md +++ b/notes/2.12.md @@ -86,6 +86,10 @@ If you were previously using the `OpenLayers.Layer.SphericalMercator.forwardMerc `OpenLayers.Protocol.HTTP` no longer requires `OpenLayers.Format.QueryStringFilter`. It you need this, make sure it is included in your build config file. +## Changes in getURLasync + +The internal `OpenLayers.Layer.getURLasync` function now take a bound, a callback and a scope. The function no longer needs update the passed property but simply to return to url. + ## 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/Strategy/BBOX.html b/tests/Strategy/BBOX.html index 026a13d474..c0ff4ff401 100644 --- a/tests/Strategy/BBOX.html +++ b/tests/Strategy/BBOX.html @@ -80,7 +80,7 @@ strategy.update({force: true}); var from = map.getProjectionObject(); var to = layer.projection; - t.ok(strategy.bounds.equals(map.getExtent().transform(from, to)), "[force update different proj] bounds transformed"); + t.eq(strategy.bounds.toString(), map.getExtent().transform(from, to).toString(), "[force update different proj] bounds transformed"); } diff --git a/tests/Tile.html b/tests/Tile.html index 9c0743a8d9..97120abc4e 100644 --- a/tests/Tile.html +++ b/tests/Tile.html @@ -22,7 +22,7 @@ function test_Tile_constructor (t) { - t.plan( 12 ); + t.plan( 13 ); setUp(); @@ -33,7 +33,11 @@ var url = "bobob"; var size = new OpenLayers.Size(5,6); - tile = new OpenLayers.Tile(layer, position, bounds, url, size); + tile = new OpenLayers.Tile(layer, position, bounds, url, size, { + eventListeners: { + loadstart: OpenLayers.Function.False + } + }); t.ok(tile instanceof OpenLayers.Tile, "new OpenLayers.Tile returns Tile object"); t.ok(tile.layer === layer, "tile.layer set correctly"); @@ -48,7 +52,9 @@ t.ok(tile.id != null, "tile is given an id"); t.ok(OpenLayers.String.startsWith(tile.id, "Tile_"), "tile's id starts correctly"); - t.ok(tile.events != null, "tile's events intitialized"); + t.ok(tile.events != null, "tile's events initialized"); + t.ok(tile.events.listeners.loadstart.length == 1, + "tile's events initialized from eventListeners option"); tearDown(); diff --git a/tests/Tile/Image.html b/tests/Tile/Image.html index 9b00113eea..0b42064265 100644 --- a/tests/Tile/Image.html +++ b/tests/Tile/Image.html @@ -85,9 +85,8 @@ var layer = new OpenLayers.Layer.WMS( "Name", "http://labs.metacarta.com/TESTURL?", - {layers: 'basic'}, {async: true, getURLasync: function(bounds, scope, url, callback) { - scope.url = this.getURL(bounds); - callback.call(scope); + {layers: 'basic'}, {async: true, getURLasync: function(bounds, callback, scope) { + callback.call(scope, this.getURL(bounds)); }} ); map.addLayer(layer);