diff --git a/lib/OpenLayers/Marker.js b/lib/OpenLayers/Marker.js index 898ed7c517..afd48b3e4c 100644 --- a/lib/OpenLayers/Marker.js +++ b/lib/OpenLayers/Marker.js @@ -27,16 +27,23 @@ OpenLayers.Marker.prototype = { this.icon = icon; this.lonlat = lonlat; }, + + /** + * @param {OpenLayers.Pixel} pixel + * + * @return A new DOM Image with this markerīs icon set at the + * location passed-in + * @type DOMElement + */ generateMarker: function(pixel) { // Create a div here, and set the location to the pixel above modified // by the icon size. - var markerObject = OpenLayers.Util.createImage( - this.icon.url, - this.icon.size, - new OpenLayers.Pixel( - pixel.x-(this.icon.size.w/2), - pixel.y-this.icon.size.h) - ); + var markerOffset = new OpenLayers.Pixel(this.icon.size.w / 2, + this.icon.size.h); + var iconPosition = pixel.diff(markerOffset); + var markerObject = OpenLayers.Util.createImage(this.icon.url, + this.icon.size, + iconPosition); return markerObject; } }