From 5804cc6cb3e470be571ee546599b01c436119d4c Mon Sep 17 00:00:00 2001 From: euzuro Date: Tue, 26 Sep 2006 21:46:10 +0000 Subject: [PATCH] small cleanup of basic OpenLayers.Feature functionality -- specifically adding full control for popup and marker creation and destruction and better comments for all that. all tests pass. git-svn-id: http://svn.openlayers.org/trunk/openlayers@1503 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Feature.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Feature.js b/lib/OpenLayers/Feature.js index d701664745..e78e4e2cfc 100644 --- a/lib/OpenLayers/Feature.js +++ b/lib/OpenLayers/Feature.js @@ -67,7 +67,7 @@ OpenLayers.Feature.prototype= { this.marker = null; } if (this.popup != null) { - this.popup.destroy(); + this.destroyPopup(this.popup); this.popup = null; } }, @@ -76,7 +76,10 @@ OpenLayers.Feature.prototype= { /** * @returns A Marker Object created from the 'lonlat' and 'icon' properties * set in this.data. If no 'lonlat' is set, returns null. If no - * 'icon' is set, OpenLayers.Marker() will load the default image + * 'icon' is set, OpenLayers.Marker() will load the default image. + * + * Note: this.marker is set to return value + * * @type OpenLayers.Marker */ createMarker: function() { @@ -89,12 +92,24 @@ OpenLayers.Feature.prototype= { return this.marker; }, + /** If user overrides the createMarker() function, s/he should be able + * to also specify an alternative function for destroying it + */ destroyMarker: function() { this.marker.destroy(); }, /** + * @returns A Popup Object created from the 'lonlat', 'popupSize', + * and 'popupContentHTML' properties set in this.data. It uses + * this.marker.icon as default anchor. + * + * If no 'lonlat' is set, returns null. + * If no this.marker has been created, no anchor is sent. * + * Note: this.popup is set to return value + * + * @type OpenLayers.Popup.AnchoredBubble */ createPopup: function() { @@ -112,5 +127,13 @@ OpenLayers.Feature.prototype= { return this.popup; }, + + /** As with the marker, if user overrides the createPopup() function, s/he + * should also be able to override the destruction + */ + destroyPopup: function() { + this.popup.destroy() + }, + CLASS_NAME: "OpenLayers.Feature" };