diff --git a/lib/OpenLayers/Icon.js b/lib/OpenLayers/Icon.js index 66cbc990af..dfa11f4555 100644 --- a/lib/OpenLayers/Icon.js +++ b/lib/OpenLayers/Icon.js @@ -29,7 +29,7 @@ OpenLayers.Icon.prototype = { this.offset = offset; if (offset == null) { // default offset - this.offset = new OpenLayers.Pixel(size.w / 2, size.h); + this.offset = new OpenLayers.Pixel(-(size.w / 2), -size.h); } }, diff --git a/lib/OpenLayers/Marker.js b/lib/OpenLayers/Marker.js index 679767dbe2..7282da55ee 100644 --- a/lib/OpenLayers/Marker.js +++ b/lib/OpenLayers/Marker.js @@ -38,7 +38,7 @@ OpenLayers.Marker.prototype = { generateMarker: function(pixel) { // Create a div here, and set the location to the pixel above modified // by the icon size. - var iconPosition = pixel.diff(this.icon.offset); + var iconPosition = pixel.add(this.icon.offset.x, this.icon.offset.y); var markerObject = OpenLayers.Util.createImage(this.icon.url, this.icon.size, iconPosition); diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index c3dd3bd0b2..eeeaf5fcf8 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -44,27 +44,6 @@ OpenLayers.Pixel.prototype = { return new OpenLayers.Pixel(this.x, this.y); }, - /** - * @param {OpenLayers.Pixel} px - * - * @return a Pixel object with the difference between the two pixels - * @type OpenLayers.Pixel - */ - diff:function(px) { - return new OpenLayers.Pixel(this.x - px.x, this.y - px.y); - }, - - /** - * @param {OpenLayers.Pixel} px - * - * @return Pixel object with the absolute difference between the two pixels - * @type OpenLayers.Pixel - */ - diffABS:function(px) { - return new OpenLayers.Pixel(Math.abs(this.x - px.x), - Math.abs(this.y - px.y)); - }, - /** * @param {OpenLayers.Pixel} px * @@ -72,8 +51,7 @@ OpenLayers.Pixel.prototype = { * @type bool */ equals:function(px) { - var d = this.diff(px); - return ((d.x == 0) && (d.y == 0)); + return ((this.x == px.x) && (this.y == px.y)); }, /** diff --git a/tests/test_Pixel.html b/tests/test_Pixel.html index 97f4e8741c..71a3d4df95 100644 --- a/tests/test_Pixel.html +++ b/tests/test_Pixel.html @@ -31,36 +31,6 @@ t.eq( pixel.x, 5, "changing oldPixel.x doesn't change pixel.x"); } - function test_04_Pixel_diff(t) { - t.plan( 4 ); - - pixelA = new OpenLayers.Pixel(10,100); - pixelB = new OpenLayers.Pixel(15,150); - - diffpx = pixelA.diff(pixelB); - t.eq( pixelA.x, 10, "pixelA.x is not modified by diff operation"); - t.eq( pixelA.y, 100, "pixelA.y is not modified by diff operation"); - - t.eq( diffpx.x, -5, "diffpx.x is set correctly"); - t.eq( diffpx.y, -50, "diffpx.y is set correctly"); - - } - - function test_05_Pixel_diffABS(t) { - t.plan( 4 ); - - pixelA = new OpenLayers.Pixel(10,100); - pixelB = new OpenLayers.Pixel(15,150); - - diffABSpx = pixelA.diffABS(pixelB); - t.eq( pixelA.x, 10, "pixelA.x is not modified by diffABS operation"); - t.eq( pixelA.y, 100, "pixelA.y is not modified by diffABS operation"); - - t.eq( diffABSpx.x, 5, "diffABSpx.x is set correctly"); - t.eq( diffABSpx.y, 50, "diffABSpx.y is set correctly"); - } - - function test_06_Pixel_equals(t) { t.plan( 4 ); pixel = new OpenLayers.Pixel(5,6);