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
This commit is contained in:
euzuro
2006-05-29 09:42:46 +00:00
parent 3f44628b44
commit 14ddfc21f3

View File

@@ -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"