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; diff --git a/lib/OpenLayers/Control/GetFeature.js b/lib/OpenLayers/Control/GetFeature.js index 650370224c..98ac1cfdc8 100644 --- a/lib/OpenLayers/Control/GetFeature.js +++ b/lib/OpenLayers/Control/GetFeature.js @@ -294,17 +294,20 @@ 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; 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/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} + * 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; 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); - - return new OpenLayers.LonLat(center.lon + delta_x * res , - center.lat - delta_y * res); + var deltaX = overviewMapPx.x - (size.w / 2); + var deltaY = overviewMapPx.y - (size.h / 2); + + return { + lon: center.lon + deltaX * res, + lat: center.lat - deltaY * res + }; }, /** @@ -700,19 +707,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' 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/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 { 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; diff --git a/lib/OpenLayers/Icon.js b/lib/OpenLayers/Icon.js index 4d6cbd0240..561e992a68 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, @@ -53,7 +56,8 @@ OpenLayers.Icon = OpenLayers.Class({ /** * Property: px - * {} + * {|Object} An OpenLayers.Pixel or an object + * with a 'x' and 'y' properties. */ px: null, @@ -62,14 +66,18 @@ 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) { 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_"); @@ -107,7 +115,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) { @@ -134,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 @@ -153,7 +163,6 @@ OpenLayers.Icon = OpenLayers.Class({ /** * Method: erase * Erase the underlying image element. - * */ erase: function() { if (this.imageDiv != null && this.imageDiv.parentNode != null) { @@ -179,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 @@ -194,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 + }); } } }, diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js index 25df080238..76483876e9 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/Layer/Boxes.js b/lib/OpenLayers/Layer/Boxes.js index f6febd9516..91c3d49cad 100644 --- a/lib/OpenLayers/Layer/Boxes.js +++ b/lib/OpenLayers/Layer/Boxes.js @@ -38,18 +38,21 @@ 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 { - 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; 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/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))); }, diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index ff815125ee..8c80623a7f 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -645,8 +645,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] = []; @@ -1002,9 +1004,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) { 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/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 3514e857c7..d440ce6a16 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. */ @@ -1469,16 +1471,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; - - 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 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; @@ -1517,9 +1516,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; }, @@ -1714,7 +1714,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} + * viewPortPx - {|Object} An OpenLayers.Pixel or + * an object with a 'x' + * and 'y' properties. * * Returns: * {} An OpenLayers.LonLat which is the passed-in view @@ -2385,7 +2391,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 diff --git a/lib/OpenLayers/Marker.js b/lib/OpenLayers/Marker.js index f114efcd9b..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)) { @@ -181,9 +182,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 + }); } }, @@ -231,13 +233,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}); }; 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"; 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} diff --git a/tests/Layer/Grid.html b/tests/Layer/Grid.html index 21b5105d89..21d0f4c5b0 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() { diff --git a/tests/Map.html b/tests/Map.html index 54898b9ea9..0f0e030219 100644 --- a/tests/Map.html +++ b/tests/Map.html @@ -1421,6 +1421,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) {