Module Template: Toggle button
From MapbenderWiki
This is a tutorial for Mapbender 2.7 and newer (note: this equals trunk at the moment, September 2009).
Contents |
Requirements
This tutorials build upon "How to Write a Mapbender module". Make sure to have read it.
Objective
Create a new module for Mapbender, which is a toggle button. On mouse over, the button is highlighted. On click, the button is activated, and complex actions may be executed. After the action has been executed, the button can be deactivated.
Template
var that = this;
Mapbender.events.init.register(function () {
var button = new Mapbender.Button({
domElement: that,
over: options.src.replace(/_off/, "_over"),
on: options.src.replace(/_off/, "_on"),
off: options.src,
name: options.id,
go: function () {
//
// enter your code here (button is clicked)
//
},
stop: function () {
//
// enter your code here (button is released)
//
}
});
});
