Files
openlayers/lib/OpenLayers/Marker.js
2006-05-26 03:17:47 +00:00

76 lines
1.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* @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, data) {
this.icon = icon;
this.lonlat = lonlat;
this.data = data;
this.image = OpenLayers.Util.createImage(null,
null,
this.icon.size,
this.icon.url,
"absolute"
);
this.events = new OpenLayers.Events(this, this.image, null);
//load marker events from data
if (this.data != null && this.data.loadEvents != null) {
this.data.loadEvents(this);
}
},
/**
* @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.moveTo(px);
return this.image;
},
/**
* @param {OpenLayers.Pixel} px
*/
moveTo: function (px) {
if ((px != null) && (this.image != 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"
}