From f67177cf2132124ea01f076b79072301920a7885 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Sat, 20 May 2006 13:28:28 +0000 Subject: [PATCH] Add Feature.createMarker method. Not complete yet. git-svn-id: http://svn.openlayers.org/trunk/openlayers@212 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Feature.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Feature.js b/lib/OpenLayers/Feature.js index 6ebf057a8f..c1f09e4e06 100644 --- a/lib/OpenLayers/Feature.js +++ b/lib/OpenLayers/Feature.js @@ -19,6 +19,23 @@ OpenLayers.Feature.prototype= { }, + createMarker: function(layer) { + if (this.lonlat && this.data.iconURL + && this.data.iconW + && this.data.iconH) { + var size = new OpenLayers.Size(this.data.iconW, this.data.iconH); + var icon = new OpenLayers.Icon(this.data.iconURL, size); + var marker = new OpenLayers.Marker(icon,this.lonlat); + if (this.title) { + var popup = new OpenLayers.Popup(this.latlon, + this.getContentHTML()); + marker.events.register('click', this, popup.open()); + } + this.marker = marker; + layer.addMarker(marker); + } + }, + /** html content based on feature information * * ret(str): @@ -31,7 +48,7 @@ OpenLayers.Feature.prototype= { contentHTML += "
" contentHTML += "" - contentHTML += this.data['title']; + contentHTML += this.data.title; contentHTML += "" contentHTML += "
"