diff --git a/examples/popups.html b/examples/popups.html index 2368008958..2b6855c17c 100644 --- a/examples/popups.html +++ b/examples/popups.html @@ -37,7 +37,8 @@ popup = new OpenLayers.Popup("chicken", new OpenLayers.LonLat(5,40), new OpenLayers.Size(200,200), - "example popup"); + "example popup", + true); map.addPopup(popup); } diff --git a/img/close.gif b/img/close.gif new file mode 100644 index 0000000000..a8958de9b4 Binary files /dev/null and b/img/close.gif differ diff --git a/lib/OpenLayers/Popup.js b/lib/OpenLayers/Popup.js index bef6915104..ed2242289e 100644 --- a/lib/OpenLayers/Popup.js +++ b/lib/OpenLayers/Popup.js @@ -60,8 +60,9 @@ OpenLayers.Popup.prototype = { * @param {OpenLayers.LonLat} lonlat * @param {OpenLayers.Size} size * @param {String} contentHTML + * @param {Boolean} closeBox */ - initialize:function(id, lonlat, size, contentHTML) { + initialize:function(id, lonlat, size, contentHTML, closeBox) { if (id == null) { id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_"); } @@ -90,6 +91,23 @@ OpenLayers.Popup.prototype = { this.contentDiv.className = 'olPopupContent'; this.div.appendChild(this.contentDiv); + if (closeBox == true) { + // close icon + var closeSize = new OpenLayers.Size(17,17); + var img = OpenLayers.Util.getImagesLocation() + "close.gif"; + var closeImg = OpenLayers.Util.createAlphaImageDiv(this.id + "_close", + null, + closeSize, + img); + closeImg.style.right = this.padding + "px"; + closeImg.style.top = this.padding + "px"; + this.div.appendChild(closeImg); + + var closeEvents = new OpenLayers.Events(this, closeImg); + closeEvents.register("mousedown", this, this.hide); + + } + this.registerEvents(); }, diff --git a/lib/OpenLayers/Popup/Anchored.js b/lib/OpenLayers/Popup/Anchored.js index f78c47fa12..a9b39edfad 100644 --- a/lib/OpenLayers/Popup/Anchored.js +++ b/lib/OpenLayers/Popup/Anchored.js @@ -31,9 +31,10 @@ OpenLayers.Popup.Anchored.prototype = * - 'size' (OpenLayers.Size) and * - 'offset' (OpenLayers.Pixel) * (this is generally an OpenLayers.Icon) + * @param {Boolean} closeBox */ - initialize:function(id, lonlat, size, contentHTML, anchor) { - var newArguments = new Array(id, lonlat, size, contentHTML); + initialize:function(id, lonlat, size, contentHTML, anchor, closeBox) { + var newArguments = new Array(id, lonlat, size, contentHTML, closeBox); OpenLayers.Popup.prototype.initialize.apply(this, newArguments); this.anchor = (anchor != null) ? anchor diff --git a/lib/OpenLayers/Popup/AnchoredBubble.js b/lib/OpenLayers/Popup/AnchoredBubble.js index a4da2dc4da..4b271cff68 100644 --- a/lib/OpenLayers/Popup/AnchoredBubble.js +++ b/lib/OpenLayers/Popup/AnchoredBubble.js @@ -28,8 +28,9 @@ OpenLayers.Popup.AnchoredBubble.prototype = * - 'size' (OpenLayers.Size) and * - 'offset' (OpenLayers.Pixel) * (this is generally an OpenLayers.Icon) + * @param {Boolean} closeBox */ - initialize:function(id, lonlat, size, contentHTML, anchor) { + initialize:function(id, lonlat, size, contentHTML, anchor, closeBox) { OpenLayers.Popup.Anchored.prototype.initialize.apply(this, arguments); },