[OpenLayers-Users] Problem connection events to custom buttons...

Adam Fowler adamfowleruk at gmail.com
Tue Mar 31 13:57:32 EDT 2009


Hi All,

I've followed all the documentation I could find regarding custom
buttons and attaching events. I have tried the following code options
to no avail. Help would be appreciated.

1)
var buttonzos = new OpenLayers.Control.Button({displayClass:
"ZoomToOSButton", active: true, trigger: function() {alert("zos");}});
// have also tried trigger: RoutePlanner.zoomToOs where zoomToOs is a
variable within RoutePlanner containing a function.

2)
var buttonzm = new OpenLayers.Control.Button({displayClass: "ZoomModeButton"});
    buttonzm.events.register("activate",buttonzm, function(e) {
	    alert("butclick");
    });

3)
var buttonzm = new OpenLayers.Control.Button({displayClass: "ZoomModeButton"});
    map.events.register("activate",buttonzm, function(e) {
	    alert("butclick");
    });
// note the map.events in number 3, as opposed to buttonzm.events in number 2

3 does indeed work, but fires no matter where you click on the map,
not just on the button.

I'm sure what I need is obvious, but nothing is working for me.

Thanks in advance.

Adam.



More information about the Users mailing list