Changeset 3226
- Timestamp:
- 06/03/07 15:43:50 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/elemoine/testing/examples/markersTextLayer.html
r1592 r3226 21 21 map.addLayer(layer); 22 22 23 var newl = new OpenLayers.Layer.Text( "text", {location: "./textfile.txt"} ); 23 var newl = new OpenLayers.Layer.Text( "text", { 24 location: "./textfile.txt", 25 callbacks: { 26 mouseover: callback 27 } 28 }); 24 29 map.addLayer(newl); 25 30 … … 27 32 map.zoomToMaxExtent(); 28 33 } 34 35 function callback(evt) { 36 for (var i = 0; i < map.popups.length; i++) { 37 map.removePopup(map.popups[i]); 38 } 39 map.addPopup(this.createPopup(true)); 40 OpenLayers.Event.stop(evt); 41 } 42 29 43 // --> 30 44 </script> sandbox/elemoine/testing/lib/OpenLayers/Layer/Text.js
r2820 r3226 18 18 location:null, 19 19 20 /** 21 * Hashtable of event callbacks - keys are event names, values 22 * are callback functions. 23 * @type Object */ 24 callbacks: null, 25 20 26 /** @type Array(OpenLayers.Feature) */ 21 27 features: null, … … 36 42 if (this.location != null) { 37 43 OpenLayers.loadURL(this.location, null, this, this.parseData); 44 } 45 if (this.callbacks == null) { 46 // if no callback passed use default onclick callback 47 this.callbacks = { click: this.markerClick }; 38 48 } 39 49 }, … … 128 138 var marker = feature.createMarker(); 129 139 if ((title != null) && (description != null)) { 130 marker.events.register('click', feature, this.markerClick); 140 for (var callback in this.callbacks) { 141 marker.events.register(callback, feature, this.callbacks[callback]); 142 } 131 143 } 132 144 this.addMarker(marker);
