git-svn-id: http://svn.openlayers.org/trunk/openlayers@366 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
69 lines
1.7 KiB
JavaScript
69 lines
1.7 KiB
JavaScript
/**
|
||
* @class
|
||
*/
|
||
OpenLayers.Marker = Class.create();
|
||
OpenLayers.Marker.prototype = {
|
||
|
||
/** @type OpenLayers.Icon */
|
||
icon: null,
|
||
|
||
/** location of object
|
||
* @type OpenLayers.LonLat */
|
||
lonlat: null,
|
||
|
||
/** @type OpenLayers.Events*/
|
||
events: null,
|
||
|
||
/** @type OpenLayers.Map */
|
||
map: null,
|
||
|
||
/** @type Object */
|
||
data: null,
|
||
|
||
/** @type DOMElement */
|
||
image: null,
|
||
|
||
/**
|
||
* @constructor
|
||
*
|
||
* @param {OpenLayers.Icon} icon
|
||
* @param {OpenLayers.LonLat lonlat
|
||
*/
|
||
initialize: function(lonlat, icon) {
|
||
this.icon = icon;
|
||
this.lonlat = lonlat;
|
||
this.image = OpenLayers.Util.createImage(this.icon.url,
|
||
this.icon.size,
|
||
null,
|
||
"absolute"
|
||
);
|
||
this.events = new OpenLayers.Events(this, this.image, null);
|
||
},
|
||
|
||
/**
|
||
* @param {OpenLayers.Pixel} px
|
||
*
|
||
* @return A new DOM Image with this marker´s icon set at the
|
||
* location passed-in
|
||
* @type DOMElement
|
||
*/
|
||
draw: function(px) {
|
||
this.image.style.top = (px.y + this.icon.offset.y) + "px"
|
||
this.image.style.left = (px.x + this.icon.offset.x) + "px";
|
||
return this.image;
|
||
},
|
||
|
||
/**
|
||
* @param {OpenLayers.Pixel} px
|
||
*/
|
||
moveTo: function (px) {
|
||
if ((px != null) && (this.div != null)) {
|
||
this.image.style.top = (px.y + this.icon.offset.y) + "px"
|
||
this.image.style.left = (px.x + this.icon.offset.x) + "px";
|
||
}
|
||
},
|
||
|
||
/** @final @type String */
|
||
CLASS_NAME: "OpenLayers.Marker"
|
||
}
|