From b8d6aaed6465fbd504c1f7db9e398f8d6db21899 Mon Sep 17 00:00:00 2001 From: euzuro Date: Mon, 29 May 2006 09:50:56 +0000 Subject: [PATCH] have the 'data' property just set an OpenLayers.Icon object. Remove default marker image loading code as it has been bubbled down into OpenLayers.Marker. git-svn-id: http://svn.openlayers.org/trunk/openlayers@441 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Feature.js | 47 +++++++++++++-------------------------- 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/lib/OpenLayers/Feature.js b/lib/OpenLayers/Feature.js index 516f7abc0c..18c325bdcb 100644 --- a/lib/OpenLayers/Feature.js +++ b/lib/OpenLayers/Feature.js @@ -19,9 +19,6 @@ OpenLayers.Feature.prototype= { /** @type Object */ data:null, - /** @type OpenLayers.Icon */ - icon: null, - /** @type OpenLayers.Marker */ marker: null, @@ -40,7 +37,7 @@ OpenLayers.Feature.prototype= { this.layer = layer; this.lonlat = lonlat; this.data = (data != null) ? data : new Object(); - this.id = (id ? id : 'f'+Math.random()); + this.id = (id ? id : 'f' + Math.random()); }, /** @@ -52,27 +49,17 @@ 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 + * @type OpenLayers.Marker */ createMarker: function() { - var imgLocation = OpenLayers.Util.getImagesLocation(); - + var marker = null; + if (this.lonlat != null) { - - var imgURL = (this.data.iconURL) ? this.data.iconURL - : imgLocation + "marker.png"; - - var imgSize = (this.data.iconSize) ? this.data.iconSize - : new OpenLayers.Size(21, 25); - - var imgOffset = (this.data.iconOffset) ? this.data.iconOffset - : null; - - this.icon = new OpenLayers.Icon(imgURL, imgSize, imgOffset); - - this.marker = new OpenLayers.Marker(this.lonlat, - this.icon); + this.marker = new OpenLayers.Marker(this.lonlat, this.data.icon); } return this.marker; }, @@ -84,16 +71,14 @@ OpenLayers.Feature.prototype= { if (this.lonlat != null) { - if (this.marker) { - var anchorSize = this.marker.icon.size; - } - - this.popup = - new OpenLayers.Popup.AnchoredBubble(this.id + "_popup", - this.lonlat, - this.data.popupSize, - this.data.popupContentHTML, - anchorSize); + var id = this.id + "_popup"; + var anchor = (this.marker) ? this.marker.icon : null; + + this.popup = new OpenLayers.Popup.AnchoredBubble(id, + this.lonlat, + this.data.popupSize, + this.data.popupContentHTML, + anchor); } return this.popup; },