diff --git a/lib/OpenLayers/Marker.js b/lib/OpenLayers/Marker.js index 7282da55ee..4b560f7522 100644 --- a/lib/OpenLayers/Marker.js +++ b/lib/OpenLayers/Marker.js @@ -18,7 +18,10 @@ OpenLayers.Marker.prototype = { /** @type OpenLayers.Map */ map: null, - + object: null, + + events:null, + /** * @param {OpenLayers.Icon} icon * @param {OpenLayers.LonLat lonlat @@ -26,6 +29,12 @@ OpenLayers.Marker.prototype = { initialize: function(icon, lonlat) { this.icon = icon; this.lonlat = lonlat; + this.object = OpenLayers.Util.createImage( + this.icon.url, + this.icon.size + ); + this.events = new OpenLayers.Events(this, this.object, null); + this.events.register("click", this, this.onclick ); }, /** @@ -38,13 +47,14 @@ OpenLayers.Marker.prototype = { generateMarker: function(pixel) { // Create a div here, and set the location to the pixel above modified // by the icon size. - var iconPosition = pixel.add(this.icon.offset.x, this.icon.offset.y); - var markerObject = OpenLayers.Util.createImage(this.icon.url, - this.icon.size, - iconPosition); - return markerObject; - }, - + this.object.style.top = (pixel.y+this.icon.offset.y) + "px" + this.object.style.left = (pixel.x+this.icon.offset.x) + "px"; + this.object.onclick = this.onclick; + return this.object; + }, + onclick: function(evt) { + alert('onclick'); + } /** @final @type String */ CLASS_NAME: "OpenLayers.Marker" }