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

View File

@@ -56,7 +56,8 @@ OpenLayers.Icon = OpenLayers.Class({
/**
* Property: px
* {<OpenLayers.Pixel>}
* {<OpenLayers.Pixel>|Object} An OpenLayers.Pixel or an object
* with a 'x' and 'y' properties.
*/
px: null,
@@ -142,7 +143,8 @@ OpenLayers.Icon = OpenLayers.Class({
* Move the div to the given pixel.
*
* Parameters:
* px - {<OpenLayers.Pixel>}
* px - {<OpenLayers.Pixel>|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
@@ -161,7 +163,6 @@ OpenLayers.Icon = OpenLayers.Class({
/**
* Method: erase
* Erase the underlying image element.
*
*/
erase: function() {
if (this.imageDiv != null && this.imageDiv.parentNode != null) {
@@ -187,7 +188,8 @@ OpenLayers.Icon = OpenLayers.Class({
* move icon to passed in px.
*
* 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) {
//if no px passed in, use stored location
@@ -202,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
});
}
}
},