Update OpenLayers.Icon.px type

'px' can be either a Pixel or a simple javascript object.
This commit is contained in:
fredj
2012-01-16 09:06:59 +01:00
parent 27a9ec26b0
commit e6ab34bed1
+10 -6
View File
@@ -56,7 +56,8 @@ OpenLayers.Icon = OpenLayers.Class({
/** /**
* Property: px * Property: px
* {<OpenLayers.Pixel>} * {<OpenLayers.Pixel>|Object} An OpenLayers.Pixel or an object
* with a 'x' and 'y' properties.
*/ */
px: null, px: null,
@@ -142,7 +143,8 @@ OpenLayers.Icon = OpenLayers.Class({
* Move the div to the given pixel. * Move the div to the given pixel.
* *
* Parameters: * Parameters:
* px - {<OpenLayers.Pixel>} * px - {<OpenLayers.Pixel>|Object} An OpenLayers.Pixel or an
* object with a 'x' and 'y' properties.
* *
* Returns: * Returns:
* {DOMElement} A new DOM Image of this icon set at the location passed-in * {DOMElement} A new DOM Image of this icon set at the location passed-in
@@ -161,7 +163,6 @@ OpenLayers.Icon = OpenLayers.Class({
/** /**
* Method: erase * Method: erase
* Erase the underlying image element. * Erase the underlying image element.
*
*/ */
erase: function() { erase: function() {
if (this.imageDiv != null && this.imageDiv.parentNode != null) { if (this.imageDiv != null && this.imageDiv.parentNode != null) {
@@ -187,7 +188,8 @@ OpenLayers.Icon = OpenLayers.Class({
* move icon to passed in px. * move icon to passed in px.
* *
* Parameters: * Parameters:
* px - {<OpenLayers.Pixel>} * px - {<OpenLayers.Pixel>|Object} the pixel position to move to.
* An OpenLayers.Pixel or an object with a 'x' and 'y' properties.
*/ */
moveTo: function (px) { moveTo: function (px) {
//if no px passed in, use stored location //if no px passed in, use stored location
@@ -202,8 +204,10 @@ OpenLayers.Icon = OpenLayers.Class({
if (this.calculateOffset) { if (this.calculateOffset) {
this.offset = this.calculateOffset(this.size); this.offset = this.calculateOffset(this.size);
} }
var offsetPx = this.px.offset(this.offset); OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv, null, {
OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv, null, offsetPx); x: this.px.x + this.offset.x,
y: this.px.y + this.offset.y
});
} }
} }
}, },