OpenLayers OpenLayers

Changeset 3226

Show
Ignore:
Timestamp:
06/03/07 15:43:50 (2 years ago)
Author:
elemoine
Message:

http://trac.openlayers.org/ticket/738

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/elemoine/testing/examples/markersTextLayer.html

    r1592 r3226  
    2121            map.addLayer(layer); 
    2222 
    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            }); 
    2429            map.addLayer(newl); 
    2530 
     
    2732            map.zoomToMaxExtent(); 
    2833        } 
     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 
    2943        // --> 
    3044    </script> 
  • sandbox/elemoine/testing/lib/OpenLayers/Layer/Text.js

    r2820 r3226  
    1818    location:null, 
    1919 
     20    /** 
     21     * Hashtable of event callbacks - keys are event names, values 
     22     * are callback functions. 
     23     * @type Object */ 
     24    callbacks: null, 
     25 
    2026    /** @type Array(OpenLayers.Feature) */ 
    2127    features: null, 
     
    3642        if (this.location != null) { 
    3743            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 }; 
    3848        } 
    3949    }, 
     
    128138                      var marker = feature.createMarker(); 
    129139                      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                          } 
    131143                      } 
    132144                      this.addMarker(marker);