From 14ddfc21f3f7b0b70082ed013d49bf6bf8ea5a5d Mon Sep 17 00:00:00 2001 From: euzuro Date: Mon, 29 May 2006 09:42:46 +0000 Subject: [PATCH] If no icon value is passed to marker constructor, assemble a default icon git-svn-id: http://svn.openlayers.org/trunk/openlayers@438 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Marker.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Marker.js b/lib/OpenLayers/Marker.js index 567d19df80..633b8d3c4f 100644 --- a/lib/OpenLayers/Marker.js +++ b/lib/OpenLayers/Marker.js @@ -27,9 +27,10 @@ OpenLayers.Marker.prototype = { * @param {OpenLayers.LonLat lonlat */ initialize: function(lonlat, icon) { - this.icon = icon; this.lonlat = lonlat; + this.icon = (icon) ? icon : this.defaultIcon(); + this.image = OpenLayers.Util.createAlphaImageDiv(null, null, this.icon.size, @@ -60,6 +61,18 @@ OpenLayers.Marker.prototype = { this.image.style.left = (px.x + this.icon.offset.x) + "px"; } }, + + /** + * @returns A default OpenLayers.Icon to use for a marker + * @type OpenLayers.Icon + */ + defaultIcon: function() { + var url = OpenLayers.Util.getImagesLocation() + "marker.png"; + var size = new OpenLayers.Size(21, 25); + var offset = new OpenLayers.Pixel(-(size.w/2), -size.h); + + return new OpenLayers.Icon(url, size, offset); + } /** @final @type String */ CLASS_NAME: "OpenLayers.Marker"