From 2086a1ad95c9510e38ee13482784686a3b7b8273 Mon Sep 17 00:00:00 2001 From: euzuro Date: Thu, 18 May 2006 05:04:06 +0000 Subject: [PATCH] add 'offset' member to OpenLayers.Icon - and then use it in OpenLayers.Marker git-svn-id: http://svn.openlayers.org/trunk/openlayers@127 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Icon.js | 13 ++++++++++++- lib/OpenLayers/Marker.js | 4 +--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Icon.js b/lib/OpenLayers/Icon.js index ccf2f6b214..b6e661a84e 100644 --- a/lib/OpenLayers/Icon.js +++ b/lib/OpenLayers/Icon.js @@ -6,10 +6,21 @@ OpenLayers.Icon.prototype = { // {OpenLayers.Size}: size of image size:null, + + /** distance in pixels to offset the image when being rendered + * @type OpenLayers.Pixel */ + offset: null, - initialize: function(url, size) { + initialize: function(url, size, offset) { this.size = size; this.url = url; + + this.offset = offset; + if (offset == null) { + // default offset + this.offset = new OpenLayers.Pixel(size.w / 2, size.h); + } + }, // Create a copy of this icon. diff --git a/lib/OpenLayers/Marker.js b/lib/OpenLayers/Marker.js index 84e09ccf2c..679767dbe2 100644 --- a/lib/OpenLayers/Marker.js +++ b/lib/OpenLayers/Marker.js @@ -38,9 +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 markerOffset = new OpenLayers.Pixel(this.icon.size.w / 2, - this.icon.size.h); - var iconPosition = pixel.diff(markerOffset); + var iconPosition = pixel.diff(this.icon.offset); var markerObject = OpenLayers.Util.createImage(this.icon.url, this.icon.size, iconPosition);