From 1df5cfa1583fa28bfcd9dfb95a590dc3c25be562 Mon Sep 17 00:00:00 2001 From: fredj Date: Fri, 9 Dec 2011 10:13:11 +0100 Subject: [PATCH 01/29] replace LonLat argument with simple object (Map.getLayerPxFromLonLat) --- lib/OpenLayers/Layer/Boxes.js | 13 ++++++++----- lib/OpenLayers/Layer/Grid.js | 6 ++++-- lib/OpenLayers/Layer/Image.js | 6 ++++-- tests/Layer/Grid.html | 2 +- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/OpenLayers/Layer/Boxes.js b/lib/OpenLayers/Layer/Boxes.js index f6febd9516..a3e2f99c73 100644 --- a/lib/OpenLayers/Layer/Boxes.js +++ b/lib/OpenLayers/Layer/Boxes.js @@ -38,11 +38,14 @@ OpenLayers.Layer.Boxes = OpenLayers.Class(OpenLayers.Layer.Markers, { * marker - {} */ drawMarker: function(marker) { - var bounds = marker.bounds; - var topleft = this.map.getLayerPxFromLonLat( - new OpenLayers.LonLat(bounds.left, bounds.top)); - var botright = this.map.getLayerPxFromLonLat( - new OpenLayers.LonLat(bounds.right, bounds.bottom)); + var topleft = this.map.getLayerPxFromLonLat({ + lon: marker.bounds.left, + lat: marker.bounds.top + }); + var botright = this.map.getLayerPxFromLonLat({ + lon: marker.bounds.right, + lat: marker.bounds.bottom + }); if (botright == null || topleft == null) { marker.display(false); } else { diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index fca45f3eba..42b850bc63 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -627,8 +627,10 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { center.lon + (tileWidth/2), center.lat + (tileHeight/2)); - var ul = new OpenLayers.LonLat(tileBounds.left, tileBounds.top); - var px = this.map.getLayerPxFromLonLat(ul); + var px = this.map.getLayerPxFromLonLat({ + lon: tileBounds.left, + lat: tileBounds.top + }); if (!this.grid.length) { this.grid[0] = []; diff --git a/lib/OpenLayers/Layer/Image.js b/lib/OpenLayers/Layer/Image.js index 23d4e1c7c1..698b223a97 100644 --- a/lib/OpenLayers/Layer/Image.js +++ b/lib/OpenLayers/Layer/Image.js @@ -164,8 +164,10 @@ OpenLayers.Layer.Image = OpenLayers.Class(OpenLayers.Layer, { this.setTileSize(); //determine new position (upper left corner of new bounds) - var ul = new OpenLayers.LonLat(this.extent.left, this.extent.top); - var ulPx = this.map.getLayerPxFromLonLat(ul); + var ulPx = this.map.getLayerPxFromLonLat({ + lon: this.extent.left, + lat: this.extent.top + }); if(firstRendering) { //create the new tile diff --git a/tests/Layer/Grid.html b/tests/Layer/Grid.html index 85724378c3..254b52e63b 100644 --- a/tests/Layer/Grid.html +++ b/tests/Layer/Grid.html @@ -417,7 +417,7 @@ translatedPX = {}; layer.map = { getLayerPxFromLonLat: function(ul) { - t.ok(ul.equals(desiredUL), "correct ul passed to translation"); + t.ok(ul.lon === desiredUL.lon && ul.lat === desiredUL.lat, "correct ul passed to translation"); return translatedPX; }, getResolution: function() { From 8ef0ad8c174203b961b033f29d3693de8bda1b74 Mon Sep 17 00:00:00 2001 From: fredj Date: Fri, 6 Jan 2012 13:53:24 +0100 Subject: [PATCH 02/29] replace Pixel argument with simple object (Map.getLonLatFromViewPortPx) --- lib/OpenLayers/Layer/FixedZoomLevels.js | 26 ++++++++++--------------- lib/OpenLayers/Map.js | 7 ++++--- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/lib/OpenLayers/Layer/FixedZoomLevels.js b/lib/OpenLayers/Layer/FixedZoomLevels.js index be84a223d3..47ad10e0d3 100644 --- a/lib/OpenLayers/Layer/FixedZoomLevels.js +++ b/lib/OpenLayers/Layer/FixedZoomLevels.js @@ -213,25 +213,19 @@ OpenLayers.Layer.FixedZoomLevels = OpenLayers.Class({ * bounds of the current viewPort. */ getExtent: function () { - var extent = null; - - var size = this.map.getSize(); + var tl = this.getLonLatFromViewPortPx({ + x: 0, y: 0 + }); + var br = this.getLonLatFromViewPortPx({ + x: size.w, y: size.h + }); - var tlPx = new OpenLayers.Pixel(0,0); - var tlLL = this.getLonLatFromViewPortPx(tlPx); - - var brPx = new OpenLayers.Pixel(size.w, size.h); - var brLL = this.getLonLatFromViewPortPx(brPx); - - if ((tlLL != null) && (brLL != null)) { - extent = new OpenLayers.Bounds(tlLL.lon, - brLL.lat, - brLL.lon, - tlLL.lat); + if ((tl != null) && (br != null)) { + return new OpenLayers.Bounds(tl.lon, br.lat, br.lon, tl.lat); + } else { + return null; } - - return extent; }, /** diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 3514e857c7..fe374d9bae 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -1517,9 +1517,10 @@ OpenLayers.Map = OpenLayers.Class({ */ getCachedCenter: function() { if (!this.center && this.size) { - this.center = this.getLonLatFromViewPortPx( - new OpenLayers.Pixel(this.size.w / 2, this.size.h / 2) - ); + this.center = this.getLonLatFromViewPortPx({ + x: this.size.w / 2, + y: this.size.h / 2 + }); } return this.center; }, From 69bc0fc77250754f07a3035c8356f50ab9bca189 Mon Sep 17 00:00:00 2001 From: fredj Date: Fri, 6 Jan 2012 15:17:00 +0100 Subject: [PATCH 03/29] replace map.minPx and map.maxPx with simple objects --- lib/OpenLayers/Map.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index fe374d9bae..92f5a02da5 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -1833,10 +1833,14 @@ OpenLayers.Map = OpenLayers.Class({ var latDelta = maxExtentCenter.lat - this.center.lat; var extentWidth = Math.round(maxExtent.getWidth() / res); var extentHeight = Math.round(maxExtent.getHeight() / res); - var left = (this.size.w - extentWidth) / 2 - lonDelta / res; - var top = (this.size.h - extentHeight) / 2 - latDelta / res; - this.minPx = new OpenLayers.Pixel(left, top); - this.maxPx = new OpenLayers.Pixel(left + extentWidth, top + extentHeight); + this.minPx = { + x: (this.size.w - extentWidth) / 2 - lonDelta / res, + y: (this.size.h - extentHeight) / 2 - latDelta / res + }; + this.maxPx = { + x: this.minPx.x + Math.round(maxExtent.getWidth() / res), + y: this.minPx.y + Math.round(maxExtent.getHeight() / res) + }; } if (zoomChanged) { From a111808e062640d1cf6cc001a25997ee35710348 Mon Sep 17 00:00:00 2001 From: fredj Date: Fri, 6 Jan 2012 15:23:05 +0100 Subject: [PATCH 04/29] replace Pixel argument with simple object (Map.getLonLatFromPixel) --- lib/OpenLayers/Control/GetFeature.js | 14 ++++++++------ lib/OpenLayers/Control/SelectFeature.js | 14 ++++++++------ lib/OpenLayers/Control/ZoomBox.js | 12 ++++++++---- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/lib/OpenLayers/Control/GetFeature.js b/lib/OpenLayers/Control/GetFeature.js index 650370224c..c16d26b143 100644 --- a/lib/OpenLayers/Control/GetFeature.js +++ b/lib/OpenLayers/Control/GetFeature.js @@ -299,12 +299,14 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, { selectBox: function(position) { var bounds; if (position instanceof OpenLayers.Bounds) { - var minXY = this.map.getLonLatFromPixel( - new OpenLayers.Pixel(position.left, position.bottom) - ); - var maxXY = this.map.getLonLatFromPixel( - new OpenLayers.Pixel(position.right, position.top) - ); + var minXY = this.map.getLonLatFromPixel({ + x: position.left, + y: position.bottom + }); + var maxXY = this.map.getLonLatFromPixel({ + x: position.right, + y: position.top + }); bounds = new OpenLayers.Bounds( minXY.lon, minXY.lat, maxXY.lon, maxXY.lat ); diff --git a/lib/OpenLayers/Control/SelectFeature.js b/lib/OpenLayers/Control/SelectFeature.js index e46f540e18..3c47929feb 100644 --- a/lib/OpenLayers/Control/SelectFeature.js +++ b/lib/OpenLayers/Control/SelectFeature.js @@ -535,12 +535,14 @@ OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, { */ selectBox: function(position) { if (position instanceof OpenLayers.Bounds) { - var minXY = this.map.getLonLatFromPixel( - new OpenLayers.Pixel(position.left, position.bottom) - ); - var maxXY = this.map.getLonLatFromPixel( - new OpenLayers.Pixel(position.right, position.top) - ); + var minXY = this.map.getLonLatFromPixel({ + x: position.left, + y: position.bottom + }); + var maxXY = this.map.getLonLatFromPixel({ + x: position.right, + y: position.top + }); var bounds = new OpenLayers.Bounds( minXY.lon, minXY.lat, maxXY.lon, maxXY.lat ); diff --git a/lib/OpenLayers/Control/ZoomBox.js b/lib/OpenLayers/Control/ZoomBox.js index f8f35d51a3..7355916143 100644 --- a/lib/OpenLayers/Control/ZoomBox.js +++ b/lib/OpenLayers/Control/ZoomBox.js @@ -63,10 +63,14 @@ OpenLayers.Control.ZoomBox = OpenLayers.Class(OpenLayers.Control, { if (position instanceof OpenLayers.Bounds) { var bounds; if (!this.out) { - var minXY = this.map.getLonLatFromPixel( - new OpenLayers.Pixel(position.left, position.bottom)); - var maxXY = this.map.getLonLatFromPixel( - new OpenLayers.Pixel(position.right, position.top)); + var minXY = this.map.getLonLatFromPixel({ + x: position.left, + y: position.bottom + }); + var maxXY = this.map.getLonLatFromPixel({ + x: position.right, + y: position.top + }); bounds = new OpenLayers.Bounds(minXY.lon, minXY.lat, maxXY.lon, maxXY.lat); } else { From 3cc62c3fc88a487f147934c0e558447eca1bd4a8 Mon Sep 17 00:00:00 2001 From: fredj Date: Fri, 6 Jan 2012 15:35:48 +0100 Subject: [PATCH 05/29] replace Pixel argument with simple object (Map.getMapObjectPixelFromXY) --- lib/OpenLayers/Layer/Google/v3.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/OpenLayers/Layer/Google/v3.js b/lib/OpenLayers/Layer/Google/v3.js index 7d2d4ca67c..bf8618130a 100644 --- a/lib/OpenLayers/Layer/Google/v3.js +++ b/lib/OpenLayers/Layer/Google/v3.js @@ -337,11 +337,8 @@ OpenLayers.Layer.Google.v3 = { var lat = this.getLatitudeFromMapObjectLonLat(moLonLat); var res = this.map.getResolution(); var extent = this.map.getExtent(); - var px = new OpenLayers.Pixel( - (1/res * (lon - extent.left)), - (1/res * (extent.top - lat)) - ); - return this.getMapObjectPixelFromXY(px.x, px.y); + return this.getMapObjectPixelFromXY((1/res * (lon - extent.left)), + (1/res * (extent.top - lat))); }, From 4844baf66619cf5808ae6da5ff6c94ffcf8ea49c Mon Sep 17 00:00:00 2001 From: fredj Date: Mon, 9 Jan 2012 09:18:13 +0100 Subject: [PATCH 06/29] replace Pixel argument with simple object (Pixel.offset) --- lib/OpenLayers/Control/Graticule.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/OpenLayers/Control/Graticule.js b/lib/OpenLayers/Control/Graticule.js index 72162d46d5..142b4f3af1 100644 --- a/lib/OpenLayers/Control/Graticule.js +++ b/lib/OpenLayers/Control/Graticule.js @@ -234,8 +234,8 @@ OpenLayers.Control.Graticule = OpenLayers.Class(OpenLayers.Control, { for (var i=0; i Date: Mon, 9 Jan 2012 09:51:13 +0100 Subject: [PATCH 07/29] replace Size instances with simple object --- lib/OpenLayers/Control/OverviewMap.js | 2 +- lib/OpenLayers/Control/PanZoom.js | 2 +- lib/OpenLayers/Control/PanZoomBar.js | 14 +++++++------- lib/OpenLayers/Popup.js | 11 ++++++----- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/OpenLayers/Control/OverviewMap.js b/lib/OpenLayers/Control/OverviewMap.js index 01fe86ee3a..df057d74e9 100644 --- a/lib/OpenLayers/Control/OverviewMap.js +++ b/lib/OpenLayers/Control/OverviewMap.js @@ -41,7 +41,7 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, { * class name olControlOverviewMapElement) may have padding or other style * attributes added via CSS. */ - size: new OpenLayers.Size(180, 90), + size: {w: 180, h: 90}, /** * APIProperty: layers diff --git a/lib/OpenLayers/Control/PanZoom.js b/lib/OpenLayers/Control/PanZoom.js index 46908a9da5..959e0a8a13 100644 --- a/lib/OpenLayers/Control/PanZoom.js +++ b/lib/OpenLayers/Control/PanZoom.js @@ -87,7 +87,7 @@ OpenLayers.Control.PanZoom = OpenLayers.Class(OpenLayers.Control, { // place the controls this.buttons = []; - var sz = new OpenLayers.Size(18,18); + var sz = {w: 18, h: 18}; var centered = new OpenLayers.Pixel(px.x+sz.w/2, px.y); this._addButton("panup", "north-mini.png", centered, sz); diff --git a/lib/OpenLayers/Control/PanZoomBar.js b/lib/OpenLayers/Control/PanZoomBar.js index ad3ecf48e0..ceb7ccb215 100644 --- a/lib/OpenLayers/Control/PanZoomBar.js +++ b/lib/OpenLayers/Control/PanZoomBar.js @@ -151,7 +151,7 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, { // place the controls this.buttons = []; - var sz = new OpenLayers.Size(18,18); + var sz = {w: 18, h: 18}; if (this.panIcons) { var centered = new OpenLayers.Pixel(px.x+sz.w/2, px.y); var wposition = sz.w; @@ -198,7 +198,7 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, { var zoomsToEnd = this.map.getNumZoomLevels() - 1 - this.map.getZoom(); var slider = OpenLayers.Util.createAlphaImageDiv(id, centered.add(-1, zoomsToEnd * this.zoomStopHeight), - new OpenLayers.Size(20,9), + {w: 20, h: 9}, imgLocation, "absolute"); slider.style.cursor = "move"; @@ -217,17 +217,17 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, { "click": this.doubleClick }); - var sz = new OpenLayers.Size(); - sz.h = this.zoomStopHeight * this.map.getNumZoomLevels(); - sz.w = this.zoomStopWidth; + var sz = { + w: this.zoomStopWidth, + h: this.zoomStopHeight * this.map.getNumZoomLevels() + }; var imgLocation = OpenLayers.Util.getImageLocation("zoombar.png"); var div = null; if (OpenLayers.Util.alphaHack()) { var id = this.id + "_" + this.map.id; div = OpenLayers.Util.createAlphaImageDiv(id, centered, - new OpenLayers.Size(sz.w, - this.zoomStopHeight), + {w: sz.w, h: this.zoomStopHeight}, imgLocation, "absolute", null, "crop"); div.style.height = sz.h + "px"; diff --git a/lib/OpenLayers/Popup.js b/lib/OpenLayers/Popup.js index 2d93e4b703..36f666e73f 100644 --- a/lib/OpenLayers/Popup.js +++ b/lib/OpenLayers/Popup.js @@ -533,11 +533,12 @@ OpenLayers.Popup = OpenLayers.Class({ } else { - //make a new OL.Size object with the clipped dimensions + // make a new 'size' object with the clipped dimensions // set or null if not clipped. - var fixedSize = new OpenLayers.Size(); - fixedSize.w = (safeSize.w < realSize.w) ? safeSize.w : null; - fixedSize.h = (safeSize.h < realSize.h) ? safeSize.h : null; + var fixedSize = { + w: (safeSize.w < realSize.w) ? safeSize.w : null, + h: (safeSize.h < realSize.h) ? safeSize.h : null + }; if (fixedSize.w && fixedSize.h) { //content is too big in both directions, so we will use @@ -872,7 +873,7 @@ OpenLayers.Popup = OpenLayers.Class({ addCloseBox: function(callback) { this.closeDiv = OpenLayers.Util.createDiv( - this.id + "_close", null, new OpenLayers.Size(17, 17) + this.id + "_close", null, {w: 17, h: 17} ); this.closeDiv.className = "olPopupCloseBox"; From 1e6f56fe828f19fdebab9a11fcf6c7efd6d8507b Mon Sep 17 00:00:00 2001 From: fredj Date: Mon, 9 Jan 2012 09:59:58 +0100 Subject: [PATCH 08/29] replace Pixel argument with simple object (OverviewMap.getLonLatFromOverviewPx) --- lib/OpenLayers/Control/OverviewMap.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/OpenLayers/Control/OverviewMap.js b/lib/OpenLayers/Control/OverviewMap.js index df057d74e9..2c9bbbe345 100644 --- a/lib/OpenLayers/Control/OverviewMap.js +++ b/lib/OpenLayers/Control/OverviewMap.js @@ -659,12 +659,14 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, { * translated into lon/lat bounds for the overview map */ getMapBoundsFromRectBounds: function(pxBounds) { - var leftBottomPx = new OpenLayers.Pixel(pxBounds.left, - pxBounds.bottom); - var rightTopPx = new OpenLayers.Pixel(pxBounds.right, - pxBounds.top); - var leftBottomLonLat = this.getLonLatFromOverviewPx(leftBottomPx); - var rightTopLonLat = this.getLonLatFromOverviewPx(rightTopPx); + var leftBottomLonLat = this.getLonLatFromOverviewPx({ + x: pxBounds.left, + y: pxBounds.bottom + }); + var rightTopLonLat = this.getLonLatFromOverviewPx({ + x: pxBounds.right, + y: pxBounds.top + }); return new OpenLayers.Bounds(leftBottomLonLat.lon, leftBottomLonLat.lat, rightTopLonLat.lon, rightTopLonLat.lat); }, From 8d11b169d38d19822bacfd80d18aa73e30f2f9fb Mon Sep 17 00:00:00 2001 From: fredj Date: Mon, 9 Jan 2012 10:04:59 +0100 Subject: [PATCH 09/29] OverviewMap.getOverviewPxFromLonLat: return simple object instead of OpenLayers.Pixel --- lib/OpenLayers/Control/OverviewMap.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/OpenLayers/Control/OverviewMap.js b/lib/OpenLayers/Control/OverviewMap.js index 2c9bbbe345..54d7d6f72d 100644 --- a/lib/OpenLayers/Control/OverviewMap.js +++ b/lib/OpenLayers/Control/OverviewMap.js @@ -702,19 +702,18 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, { * lonlat - {} * * Returns: - * {} Location which is the passed-in OpenLayers.LonLat, + * {Object} Location which is the passed-in OpenLayers.LonLat, * translated into overview map pixels */ getOverviewPxFromLonLat: function(lonlat) { - var res = this.ovmap.getResolution(); + var res = this.ovmap.getResolution(); var extent = this.ovmap.getExtent(); - var px = null; if (extent) { - px = new OpenLayers.Pixel( - Math.round(1/res * (lonlat.lon - extent.left)), - Math.round(1/res * (extent.top - lonlat.lat))); + return { + x: Math.round(1/res * (lonlat.lon - extent.left)), + y: Math.round(1/res * (extent.top - lonlat.lat)) + }; } - return px; }, CLASS_NAME: 'OpenLayers.Control.OverviewMap' From f199dd471e7eaef48e023a1c7bf0bee32f6a90d7 Mon Sep 17 00:00:00 2001 From: fredj Date: Mon, 9 Jan 2012 13:42:02 +0100 Subject: [PATCH 10/29] Icon: use simple ojects for size and offset --- lib/OpenLayers/Icon.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Icon.js b/lib/OpenLayers/Icon.js index 4d6cbd0240..016121e480 100644 --- a/lib/OpenLayers/Icon.js +++ b/lib/OpenLayers/Icon.js @@ -68,8 +68,8 @@ OpenLayers.Icon = OpenLayers.Class({ */ initialize: function(url, size, offset, calculateOffset) { this.url = url; - this.size = (size) ? size : new OpenLayers.Size(20,20); - this.offset = offset ? offset : new OpenLayers.Pixel(-(this.size.w/2), -(this.size.h/2)); + this.size = size || {w: 20, h: 20}; + this.offset = offset || {x: -(this.size.w/2), y: -(this.size.h/2)}; this.calculateOffset = calculateOffset; var id = OpenLayers.Util.createUniqueID("OL_Icon_"); From 6abed6221f6032e382e500bc31fd94a303bd62b1 Mon Sep 17 00:00:00 2001 From: fredj Date: Mon, 9 Jan 2012 13:43:59 +0100 Subject: [PATCH 11/29] replace Size argument with simple object (icon.setSize) --- lib/OpenLayers/Marker.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/OpenLayers/Marker.js b/lib/OpenLayers/Marker.js index f114efcd9b..11a5dce575 100644 --- a/lib/OpenLayers/Marker.js +++ b/lib/OpenLayers/Marker.js @@ -181,9 +181,10 @@ OpenLayers.Marker = OpenLayers.Class({ */ inflate: function(inflate) { if (this.icon) { - var newSize = new OpenLayers.Size(this.icon.size.w * inflate, - this.icon.size.h * inflate); - this.icon.setSize(newSize); + this.icon.setSize({ + w: this.icon.size.w * inflate, + h: this.icon.size.h * inflate + }); } }, From 8825b329242d68e659d4a042c5500e893db9149b Mon Sep 17 00:00:00 2001 From: fredj Date: Mon, 9 Jan 2012 13:44:37 +0100 Subject: [PATCH 12/29] pass simple objects to Icon constructor --- lib/OpenLayers/Marker.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/OpenLayers/Marker.js b/lib/OpenLayers/Marker.js index 11a5dce575..dbb44a86da 100644 --- a/lib/OpenLayers/Marker.js +++ b/lib/OpenLayers/Marker.js @@ -232,13 +232,8 @@ OpenLayers.Marker = OpenLayers.Class({ * {} A default OpenLayers.Icon to use for a marker */ OpenLayers.Marker.defaultIcon = function() { - var url = OpenLayers.Util.getImageLocation("marker.png"); - var size = new OpenLayers.Size(21, 25); - var calculateOffset = function(size) { - return new OpenLayers.Pixel(-(size.w/2), -size.h); - }; - - return new OpenLayers.Icon(url, size, null, calculateOffset); + return new OpenLayers.Icon(OpenLayers.Util.getImageLocation("marker.png"), + {w: 21, h: 25}, {x: -10.5, y: -25}); }; From c440a2916db9252ac221157a90030721cbacc9dc Mon Sep 17 00:00:00 2001 From: fredj Date: Mon, 9 Jan 2012 14:26:23 +0100 Subject: [PATCH 13/29] replace Size argument with simple object (maker.draw) --- lib/OpenLayers/Layer/Boxes.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Layer/Boxes.js b/lib/OpenLayers/Layer/Boxes.js index a3e2f99c73..91c3d49cad 100644 --- a/lib/OpenLayers/Layer/Boxes.js +++ b/lib/OpenLayers/Layer/Boxes.js @@ -49,10 +49,10 @@ OpenLayers.Layer.Boxes = OpenLayers.Class(OpenLayers.Layer.Markers, { if (botright == null || topleft == null) { marker.display(false); } else { - var sz = new OpenLayers.Size( - Math.max(1, botright.x - topleft.x), - Math.max(1, botright.y - topleft.y)); - var markerDiv = marker.draw(topleft, sz); + var markerDiv = marker.draw(topleft, { + w: Math.max(1, botright.x - topleft.x), + h: Math.max(1, botright.y - topleft.y) + }); if (!marker.drawn) { this.div.appendChild(markerDiv); marker.drawn = true; From 90452311f382effbd589334670e890edc888c5dc Mon Sep 17 00:00:00 2001 From: fredj Date: Mon, 9 Jan 2012 15:16:38 +0100 Subject: [PATCH 14/29] Remove tileSize.clone; not necessary to create a new size instance --- lib/OpenLayers/Layer/Grid.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index 42b850bc63..61b9fbb330 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -979,9 +979,10 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { var offsetX = parseInt(this.map.layerContainerDiv.style.left); var offsetY = parseInt(this.map.layerContainerDiv.style.top); var tlViewPort = tlLayer.add(offsetX, offsetY); - var tileSize = this.tileSize.clone(); - tileSize.w *= scale; - tileSize.h *= scale; + var tileSize = { + w: this.tileSize.w * scale, + h: this.tileSize.h * scale + }; if (tlViewPort.x > -tileSize.w * (buffer - 1)) { this.shiftColumn(true); } else if (tlViewPort.x < -tileSize.w * buffer) { From b900144ce3bfd5def88dfbb6f3e3df472ba37ab9 Mon Sep 17 00:00:00 2001 From: fredj Date: Mon, 9 Jan 2012 16:14:18 +0100 Subject: [PATCH 15/29] remove map.getSize call to avoid creating new instances --- lib/OpenLayers/Map.js | 28 +++++++++++++--------------- tests/Map.html | 1 + 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 92f5a02da5..e7910548a9 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -1469,15 +1469,13 @@ OpenLayers.Map = OpenLayers.Class({ } if ((center != null) && (resolution != null)) { - - var size = this.getSize(); - var w_deg = size.w * resolution; - var h_deg = size.h * resolution; + var half_w_deg = (this.size.w * resolution) / 2; + var half_h_deg = (this.size.h * resolution) / 2; - extent = new OpenLayers.Bounds(center.lon - w_deg / 2, - center.lat - h_deg / 2, - center.lon + w_deg / 2, - center.lat + h_deg / 2); + extent = new OpenLayers.Bounds(center.lon - half_w_deg, + center.lat - half_h_deg, + center.lon + half_w_deg, + center.lat + half_h_deg); } @@ -2318,15 +2316,15 @@ OpenLayers.Map = OpenLayers.Class({ zoomToScale: function(scale, closest) { var res = OpenLayers.Util.getResolutionFromScale(scale, this.baseLayer.units); - var size = this.getSize(); - var w_deg = size.w * res; - var h_deg = size.h * res; + + var half_w_deg = (this.size.w * res) / 2; + var half_h_deg = (this.size.h * res) / 2; var center = this.getCachedCenter(); - var extent = new OpenLayers.Bounds(center.lon - w_deg / 2, - center.lat - h_deg / 2, - center.lon + w_deg / 2, - center.lat + h_deg / 2); + var extent = new OpenLayers.Bounds(center.lon - half_w_deg, + center.lat - half_h_deg, + center.lon + half_w_deg, + center.lat + half_h_deg); this.zoomToExtent(extent, closest); }, diff --git a/tests/Map.html b/tests/Map.html index faad0b30c7..2401ae21d6 100644 --- a/tests/Map.html +++ b/tests/Map.html @@ -1406,6 +1406,7 @@ var m = { 'baseLayer': { 'units': {} }, + 'size': {'w': 10, 'h': 15}, 'getSize': function() { return {'w': 10, 'h': 15}; }, 'getCachedCenter': function() { return {'lon': -5, 'lat': -25}; }, 'zoomToExtent': function(extent, closest) { From b8257aa64cd70854b88421cf7ba7b76e77c9409f Mon Sep 17 00:00:00 2001 From: fredj Date: Thu, 12 Jan 2012 11:23:14 +0100 Subject: [PATCH 16/29] replace Pixel argument with simple object (Util.createDiv) --- lib/OpenLayers/Handler/Box.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Handler/Box.js b/lib/OpenLayers/Handler/Box.js index 01817dc936..bbefce8679 100644 --- a/lib/OpenLayers/Handler/Box.js +++ b/lib/OpenLayers/Handler/Box.js @@ -97,8 +97,9 @@ OpenLayers.Handler.Box = OpenLayers.Class(OpenLayers.Handler, { */ startBox: function (xy) { this.callback("start", []); - this.zoomBox = OpenLayers.Util.createDiv('zoomBox', - new OpenLayers.Pixel(-9999, -9999)); + this.zoomBox = OpenLayers.Util.createDiv('zoomBox', { + x: -9999, y: -9999 + }); this.zoomBox.className = this.boxDivClassName; this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1; From 2355f099bec5d0fed5b76cd3aafd24cd893455e7 Mon Sep 17 00:00:00 2001 From: fredj Date: Thu, 12 Jan 2012 13:32:09 +0100 Subject: [PATCH 17/29] remove map.getSize call to avoid creating new instances --- lib/OpenLayers/Map.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index e7910548a9..32b04aca48 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -1713,7 +1713,7 @@ OpenLayers.Map = OpenLayers.Class({ */ adjustZoom: function(zoom) { var resolution, resolutions = this.baseLayer.resolutions, - maxResolution = this.getMaxExtent().getWidth() / this.getSize().w; + maxResolution = this.getMaxExtent().getWidth() / this.size.w; if (this.getResolutionForZoom(zoom) > maxResolution) { for (var i=zoom|0, ii=resolutions.length; i Date: Thu, 12 Jan 2012 17:31:31 +0100 Subject: [PATCH 18/29] replace LonLat with simple object (OverviewMap.getLonLatFromOverviewPx, internal function) --- lib/OpenLayers/Control/OverviewMap.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/OpenLayers/Control/OverviewMap.js b/lib/OpenLayers/Control/OverviewMap.js index 54d7d6f72d..f90fd7d54a 100644 --- a/lib/OpenLayers/Control/OverviewMap.js +++ b/lib/OpenLayers/Control/OverviewMap.js @@ -689,9 +689,11 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, { var delta_x = overviewMapPx.x - (size.w / 2); var delta_y = overviewMapPx.y - (size.h / 2); - - return new OpenLayers.LonLat(center.lon + delta_x * res , - center.lat - delta_y * res); + + return { + lon: center.lon + delta_x * res, + lat: center.lat - delta_y * res + }; }, /** From a9aa6d031e7f4bce738400bbe783bcb9255536f0 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Sun, 15 Jan 2012 10:45:27 +0100 Subject: [PATCH 19/29] Fix OpenLayers.Util apidoc 'px' and 'sz' parameters for modifyDOMElement, createDiv, createImage, createAlphaImageDiv and modifyAlphaImageDiv can be either a OpenLayers.Pixel/OpenLayers.Size or a simple javascript object. --- lib/OpenLayers/Util.js | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index 0705020330..b9f92c6c04 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -140,8 +140,12 @@ OpenLayers.Util.indexOf = function(array, obj) { * Parameters: * element - {DOMElement} DOM element to modify. * id - {String} The element id attribute to set. - * px - {} The left and top style position. - * sz - {} The width and height style attributes. + * px - {|Object} The element left and top position, + * OpenLayers.Pixel or an object with + * a 'x' and 'y' properties. + * sz - {|Object} The element width and height, + * OpenLayers.Size or an object with a + * 'w' and 'h' properties. * position - {String} The position attribute. eg: absolute, * relative, etc. * border - {String} The style.border attribute. eg: @@ -192,8 +196,12 @@ OpenLayers.Util.modifyDOMElement = function(element, id, px, sz, position, * id - {String} An identifier for this element. If no id is * passed an identifier will be created * automatically. - * px - {} The element left and top position. - * sz - {} The element width and height. + * px - {|Object} The element left and top position, + * OpenLayers.Pixel or an object with + * a 'x' and 'y' properties. + * sz - {|Object} The element width and height, + * OpenLayers.Size or an object with a + * 'w' and 'h' properties. * imgURL - {String} A url pointing to an image to use as a * background image. * position - {String} The style.position value. eg: absolute, @@ -235,8 +243,12 @@ OpenLayers.Util.createDiv = function(id, px, sz, imgURL, position, * Parameters: * id - {String} The id field for the img. If none assigned one will be * automatically generated. - * px - {} The left and top positions. - * sz - {} The style.width and style.height values. + * px - {|Object} The element left and top position, + * OpenLayers.Pixel or an object with + * a 'x' and 'y' properties. + * sz - {|Object} The element width and height, + * OpenLayers.Size or an object with a + * 'w' and 'h' properties. * imgURL - {String} The url to use as the image source. * position - {String} The style.position value. * border - {String} The border to place around the image. @@ -331,8 +343,10 @@ OpenLayers.Util.alphaHack = function() { * Parameters: * div - {DOMElement} Div containing Alpha-adjusted Image * id - {String} - * px - {} - * sz - {} + * px - {|Object} OpenLayers.Pixel or an object with + * a 'x' and 'y' properties. + * sz - {|Object} OpenLayers.Size or an object with + * a 'w' and 'h' properties. * imgURL - {String} * position - {String} * border - {String} @@ -379,8 +393,10 @@ OpenLayers.Util.modifyAlphaImageDiv = function(div, id, px, sz, imgURL, * * Parameters: * id - {String} - * px - {} - * sz - {} + * px - {|Object} OpenLayers.Pixel or an object with + * a 'x' and 'y' properties. + * sz - {|Object} OpenLayers.Size or an object with + * a 'w' and 'h' properties. * imgURL - {String} * position - {String} * border - {String} From 4d0a53ab313edb1ad70aa3358394d3a3a8f96842 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Sun, 15 Jan 2012 10:59:08 +0100 Subject: [PATCH 20/29] Fix OpenLayers.Pixel and OpenLayers.Size apidoc 'px' parameter for OpenLayers.Pixel.offset and OpenLayers.Pixel.equals can be either a Pixel or a simple javascript object. 'sz' parameter for OpenLayers.Size.equals can be either a Size or a simple javascript object. --- lib/OpenLayers/BaseTypes/Pixel.js | 6 ++++-- lib/OpenLayers/BaseTypes/Size.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/BaseTypes/Pixel.js b/lib/OpenLayers/BaseTypes/Pixel.js index 3261f01b50..4525e75b16 100644 --- a/lib/OpenLayers/BaseTypes/Pixel.js +++ b/lib/OpenLayers/BaseTypes/Pixel.js @@ -68,7 +68,8 @@ OpenLayers.Pixel = OpenLayers.Class({ * Determine whether one pixel is equivalent to another * * Parameters: - * px - {} + * px - {|Object} An OpenLayers.Pixel or an object with + * a 'x' and 'y' properties. * * Returns: * {Boolean} The point passed in as parameter is equal to this. Note that @@ -123,7 +124,8 @@ OpenLayers.Pixel = OpenLayers.Class({ * APIMethod: offset * * Parameters - * px - {} + * px - {|Object} An OpenLayers.Pixel or an object with + * a 'x' and 'y' properties. * * Returns: * {} A new Pixel with this pixel's x&y augmented by the diff --git a/lib/OpenLayers/BaseTypes/Size.js b/lib/OpenLayers/BaseTypes/Size.js index 1c0039718a..609eb5f17e 100644 --- a/lib/OpenLayers/BaseTypes/Size.js +++ b/lib/OpenLayers/BaseTypes/Size.js @@ -69,12 +69,12 @@ OpenLayers.Size = OpenLayers.Class({ * Determine where this size is equal to another * * Parameters: - * sz - {} + * sz - {|Object} An OpenLayers.Size or an object with + * a 'w' and 'h' properties. * * Returns: * {Boolean} The passed in size has the same h and w properties as this one. * Note that if sz passed in is null, returns false. - * */ equals:function(sz) { var equals = false; From 0af2acddb5e5f2a09170de0300e49ad53bb594eb Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Sun, 15 Jan 2012 17:52:36 +0100 Subject: [PATCH 21/29] Fix OpenLayers.Layer and OpenLayers.Map apidoc 'viewPortPx' parameter for OpenLayers.Layer.getLonLatFromViewPortPx can be either a Pixel or a simple javascript object. 'lonlat' parameter for OpenLayers.Layer.getViewPortPxFromLonLat can be either a LonLat or a simple javascript object. 'px' parameter for OpenLayers.Map.getLonLatFromViewPortPx and OpenLayers.Map.getLonLatFromPixel can be either a Pixel or a simple javascript object. --- lib/OpenLayers/Layer.js | 10 +++++++--- lib/OpenLayers/Map.js | 7 +++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js index fdc4edaa34..5636ece2c2 100644 --- a/lib/OpenLayers/Layer.js +++ b/lib/OpenLayers/Layer.js @@ -1227,7 +1227,9 @@ OpenLayers.Layer = OpenLayers.Class({ * APIMethod: getLonLatFromViewPortPx * * Parameters: - * viewPortPx - {} + * viewPortPx - {|Object} An OpenLayers.Pixel or + * an object with a 'x' + * and 'y' properties. * * Returns: * {} An OpenLayers.LonLat which is the passed-in @@ -1256,11 +1258,13 @@ OpenLayers.Layer = OpenLayers.Class({ * fractional pixel values. * * Parameters: - * lonlat - {} + * lonlat - {|Object} An OpenLayers.LonLat or + * an object with a 'lon' + * and 'lat' properties. * * Returns: * {} An which is the passed-in - * ,translated into view port pixels. + * lonlat translated into view port pixels. */ getViewPortPxFromLonLat: function (lonlat, resolution) { var px = null; diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 32b04aca48..b3eb75f821 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -2345,7 +2345,9 @@ OpenLayers.Map = OpenLayers.Class({ * Method: getLonLatFromViewPortPx * * Parameters: - * viewPortPx - {} + * viewPortPx - {|Object} An OpenLayers.Pixel or + * an object with a 'x' + * and 'y' properties. * * Returns: * {} An OpenLayers.LonLat which is the passed-in view @@ -2388,7 +2390,8 @@ OpenLayers.Map = OpenLayers.Class({ * APIMethod: getLonLatFromPixel * * Parameters: - * px - {} + * px - {|Object} An OpenLayers.Pixel or an object with + * a 'x' and 'y' properties. * * Returns: * {} An OpenLayers.LonLat corresponding to the given From 8f4fcc7f3358112d6dc0d66251119833801ea1d6 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Sun, 15 Jan 2012 18:03:13 +0100 Subject: [PATCH 22/29] Fix OpenLayers.Icon apidoc 'size' can be either an OpenLayers.Size or a simple javascript object, 'offset' can be either an OpenLayers.Pixel or a simple javascript object. --- lib/OpenLayers/Icon.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Icon.js b/lib/OpenLayers/Icon.js index 016121e480..708eb8623f 100644 --- a/lib/OpenLayers/Icon.js +++ b/lib/OpenLayers/Icon.js @@ -29,13 +29,16 @@ OpenLayers.Icon = OpenLayers.Class({ /** * Property: size - * {} + * {|Object} An OpenLayers.Size or + * an object with a 'w' and 'h' properties. */ size: null, /** * Property: offset - * {} distance in pixels to offset the image when being rendered + * {|Object} distance in pixels to offset the + * image when being rendered. An OpenLayers.Pixel or an object + * with a 'x' and 'y' properties. */ offset: null, @@ -62,8 +65,12 @@ OpenLayers.Icon = OpenLayers.Class({ * Creates an icon, which is an image tag in a div. * * url - {String} - * size - {} - * offset - {} + * size - {|Object} An OpenLayers.Size or an + * object with a 'w' and 'h' + * properties. + * offset - {|Object} An OpenLayers.Pixel or an + * object with a 'x' and 'y' + * properties. * calculateOffset - {Function} */ initialize: function(url, size, offset, calculateOffset) { From 5d173c18074a9cc9e79c463e160012c14896712a Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Sun, 15 Jan 2012 18:09:11 +0100 Subject: [PATCH 23/29] Fix OpenLayers.Icon apidoc 'size' parameter for OpenLayers.Icon.setSize can be either a Size or a simple javascript object. --- lib/OpenLayers/Icon.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Icon.js b/lib/OpenLayers/Icon.js index 708eb8623f..3d8fb50335 100644 --- a/lib/OpenLayers/Icon.js +++ b/lib/OpenLayers/Icon.js @@ -114,7 +114,8 @@ OpenLayers.Icon = OpenLayers.Class({ * Method: setSize * * Parameters: - * size - {} + * size - {|Object} An OpenLayers.Size or + * an object with a 'w' and 'h' properties. */ setSize: function(size) { if (size != null) { From 098899d165d8b2ce212db511bfa71191ae346059 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Sun, 15 Jan 2012 18:13:27 +0100 Subject: [PATCH 24/29] Fix OpenLayers.Control.OverviewMap.getLonLatFromOverviewPx apidoc --- lib/OpenLayers/Control/OverviewMap.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/OpenLayers/Control/OverviewMap.js b/lib/OpenLayers/Control/OverviewMap.js index f90fd7d54a..3b23300402 100644 --- a/lib/OpenLayers/Control/OverviewMap.js +++ b/lib/OpenLayers/Control/OverviewMap.js @@ -676,11 +676,14 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, { * Get a map location from a pixel location * * Parameters: - * overviewMapPx - {} + * overviewMapPx - {|Object} OpenLayers.Pixel or + * an object with a + * 'x' and 'y' properties. * * Returns: - * {} Location which is the passed-in overview map - * OpenLayers.Pixel, translated into lon/lat by the overview map + * {Object} Location which is the passed-in overview map + * OpenLayers.Pixel, translated into lon/lat by the overview + * map. An object with a 'lon' and 'lat' properties. */ getLonLatFromOverviewPx: function(overviewMapPx) { var size = this.ovmap.size; From 4e703abc0c0ca5526a23423f0ffbcf8fa909af06 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Sun, 15 Jan 2012 18:14:31 +0100 Subject: [PATCH 25/29] Fix OpenLayers.Control.GetFeature.selectBox apidoc --- lib/OpenLayers/Control/GetFeature.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Control/GetFeature.js b/lib/OpenLayers/Control/GetFeature.js index c16d26b143..98ac1cfdc8 100644 --- a/lib/OpenLayers/Control/GetFeature.js +++ b/lib/OpenLayers/Control/GetFeature.js @@ -294,7 +294,8 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, { * Callback from the handlers.box set up when selection is on * * Parameters: - * position - {} + * position - {|Object} An OpenLayers.Bounds or + * an object with a 'left', 'bottom', 'right' and 'top' properties. */ selectBox: function(position) { var bounds; From 511784d53014f67326e92c740799dc6df032eaba Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Sun, 15 Jan 2012 18:22:22 +0100 Subject: [PATCH 26/29] Update OpenLayers.Map.{min,max}Px apidoc OpenLayers.Pixel to simple javascript object. --- lib/OpenLayers/Map.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index b3eb75f821..05df48eaed 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -398,7 +398,8 @@ OpenLayers.Map = OpenLayers.Class({ /** * Property: minPx - * {} Lower left of maxExtent in viewport pixel space. + * {Object} An object with a 'x' and 'y' values that is the lower + * left of maxExtent in viewport pixel space. * Used to verify in moveByPx that the new location we're moving to * is valid. It is also used in the getLonLatFromViewPortPx function * of Layer. @@ -407,7 +408,8 @@ OpenLayers.Map = OpenLayers.Class({ /** * Property: maxPx - * {} Top right of maxExtent in viewport pixel space. + * {Object} An object with a 'x' and 'y' values that is the top + * right of maxExtent in viewport pixel space. * Used to verify in moveByPx that the new location we're moving to * is valid. */ From 27a9ec26b026b09f96045f171fac54ac88ee1ac4 Mon Sep 17 00:00:00 2001 From: fredj Date: Mon, 16 Jan 2012 09:06:13 +0100 Subject: [PATCH 27/29] Update OpenLayers.Marker.moveTo apidoc 'px' parameter can be either a Pixel or a simple javascript object. --- lib/OpenLayers/Marker.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Marker.js b/lib/OpenLayers/Marker.js index dbb44a86da..7a681d3c9c 100644 --- a/lib/OpenLayers/Marker.js +++ b/lib/OpenLayers/Marker.js @@ -135,7 +135,8 @@ OpenLayers.Marker = OpenLayers.Class({ * Move the marker to the new location. * * Parameters: - * px - {} the pixel position to move to + * px - {|Object} the pixel position to move to. + * An OpenLayers.Pixel or an object with a 'x' and 'y' properties. */ moveTo: function (px) { if ((px != null) && (this.icon != null)) { From e6ab34bed1c6922dbe5248dd9e68796fe979c503 Mon Sep 17 00:00:00 2001 From: fredj Date: Mon, 16 Jan 2012 09:06:59 +0100 Subject: [PATCH 28/29] Update OpenLayers.Icon.px type 'px' can be either a Pixel or a simple javascript object. --- lib/OpenLayers/Icon.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/OpenLayers/Icon.js b/lib/OpenLayers/Icon.js index 3d8fb50335..561e992a68 100644 --- a/lib/OpenLayers/Icon.js +++ b/lib/OpenLayers/Icon.js @@ -56,7 +56,8 @@ OpenLayers.Icon = OpenLayers.Class({ /** * Property: px - * {} + * {|Object} An OpenLayers.Pixel or an object + * with a 'x' and 'y' properties. */ px: null, @@ -142,7 +143,8 @@ OpenLayers.Icon = OpenLayers.Class({ * Move the div to the given pixel. * * Parameters: - * px - {} + * px - {|Object} An OpenLayers.Pixel or an + * object with a 'x' and 'y' properties. * * Returns: * {DOMElement} A new DOM Image of this icon set at the location passed-in @@ -161,7 +163,6 @@ OpenLayers.Icon = OpenLayers.Class({ /** * Method: erase * Erase the underlying image element. - * */ erase: function() { if (this.imageDiv != null && this.imageDiv.parentNode != null) { @@ -187,7 +188,8 @@ OpenLayers.Icon = OpenLayers.Class({ * move icon to passed in px. * * Parameters: - * px - {} + * px - {|Object} the pixel position to move to. + * An OpenLayers.Pixel or an object with a 'x' and 'y' properties. */ moveTo: function (px) { //if no px passed in, use stored location @@ -202,8 +204,10 @@ OpenLayers.Icon = OpenLayers.Class({ if (this.calculateOffset) { this.offset = this.calculateOffset(this.size); } - var offsetPx = this.px.offset(this.offset); - OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv, null, offsetPx); + OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv, null, { + x: this.px.x + this.offset.x, + y: this.px.y + this.offset.y + }); } } }, From 42fcb70347f59fce484cb6385d353586aa4aecc0 Mon Sep 17 00:00:00 2001 From: fredj Date: Mon, 16 Jan 2012 09:20:05 +0100 Subject: [PATCH 29/29] Coding standards: variable names to camel case --- lib/OpenLayers/Control/OverviewMap.js | 8 ++++---- lib/OpenLayers/Map.js | 25 ++++++++++++------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/lib/OpenLayers/Control/OverviewMap.js b/lib/OpenLayers/Control/OverviewMap.js index 3b23300402..4c92522bb0 100644 --- a/lib/OpenLayers/Control/OverviewMap.js +++ b/lib/OpenLayers/Control/OverviewMap.js @@ -690,12 +690,12 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, { var res = this.ovmap.getResolution(); var center = this.ovmap.getExtent().getCenterLonLat(); - var delta_x = overviewMapPx.x - (size.w / 2); - var delta_y = overviewMapPx.y - (size.h / 2); + var deltaX = overviewMapPx.x - (size.w / 2); + var deltaY = overviewMapPx.y - (size.h / 2); return { - lon: center.lon + delta_x * res, - lat: center.lat - delta_y * res + lon: center.lon + deltaX * res, + lat: center.lat - deltaY * res }; }, diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 05df48eaed..d440ce6a16 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -1471,14 +1471,13 @@ OpenLayers.Map = OpenLayers.Class({ } if ((center != null) && (resolution != null)) { - var half_w_deg = (this.size.w * resolution) / 2; - var half_h_deg = (this.size.h * resolution) / 2; - - extent = new OpenLayers.Bounds(center.lon - half_w_deg, - center.lat - half_h_deg, - center.lon + half_w_deg, - center.lat + half_h_deg); + var halfWDeg = (this.size.w * resolution) / 2; + var halfHDeg = (this.size.h * resolution) / 2; + extent = new OpenLayers.Bounds(center.lon - halfWDeg, + center.lat - halfHDeg, + center.lon + halfWDeg, + center.lat + halfHDeg); } return extent; @@ -2319,14 +2318,14 @@ OpenLayers.Map = OpenLayers.Class({ var res = OpenLayers.Util.getResolutionFromScale(scale, this.baseLayer.units); - var half_w_deg = (this.size.w * res) / 2; - var half_h_deg = (this.size.h * res) / 2; + var halfWDeg = (this.size.w * res) / 2; + var halfHDeg = (this.size.h * res) / 2; var center = this.getCachedCenter(); - var extent = new OpenLayers.Bounds(center.lon - half_w_deg, - center.lat - half_h_deg, - center.lon + half_w_deg, - center.lat + half_h_deg); + var extent = new OpenLayers.Bounds(center.lon - halfWDeg, + center.lat - halfHDeg, + center.lon + halfWDeg, + center.lat + halfHDeg); this.zoomToExtent(extent, closest); },