Skip to end of metadata
Go to start of metadata

The purpose of this page is to describe how Listeners are used within Javascript within MapBuilder

More advanced applications will likely want to add functionality by performing specific actions in response to user input. There are a few methods provided in MapBuilder to customize your application.

An important aspect of the MVC design pattern is that it is event driven. Almost everything that happens over the course of the application execution is the result of an event being triggered on a model, which then calls listener functions registered with that model. This allows the models, widgets and tools to remain independant of each other and makes MapBuilder very modular - objects can be added and removed from the configuration without affecting the other objects.

There is a global "config" object that can be referenced from anywhere. You can retrieve a reference to all other objects by using the config.objects property. For example, a model with an ID of "model_x" would be referenced as config.objects.model_x, or config.objects["model_x"].

The following functions are available for carrying out user actions:

This method will load the model with the specified modelId from the docUrl provided. This will also trigger a "loadModel" event for that model.
This method updates a parameter and call all interested listeners. For example, you can set an area of interest on a Context document by setting the "aoi" event as the param argument.  Any listeners registered to listen for the "aoi" event would then be called and the value is passed to the listener functions as an argument. The value can be any Javascript object, e.g. a string, integer, array, or object.  A list of the more common events that are built in to MapBuilder is listed below.
Updates the value of a node in the model's XML document and optionally triggers a "refresh" event for this model (based on the boolean refresh argument value). The xml node to be updated is specified by the xpath argument.
button action property
Buttons in the configuration file accept an <action> property which specifies an object method to be called when a button is selected.

The way to use these functions is to set them as the HREF element of an anchor tag:

or as an event handler (onclick, onmouseover, etc.) on any HTML element that allows it:


The primary events that models, widgets and tools listen for are listed below.  When calling model.setParam(param,value), the event name is the "param" argument, and the "value" argument is the JavaScript object listed.  Models will accept any event name as the param so custom widgets can define their own event types that only that custom widget will listen for.






Indicates that the configuration file has been successfully parsed and all MapBuilder JavaScript objects exist.  After the "init" event is fired, the config.objects[] property is guaranteed to exist  so you can then reference  other MapBuilder objects



 called just before a Model document is loaded



 called after a Model document is successfuilly loaded



 called to indicate that widgets should repaint themselves.  The optional "widgetId" argument indicates that only the widget with that ID should be refreshed.


 status message

called whenever the state of the model has changed.  The optional status message string describes the change in state; if it is null it indicates that the message should be cleared.


 file URL



 AOI array



 BBOX array






 SIZE array



target node



 target node



 target node



 target node



 target node




called before the prepaint method of a widget based on WidgetBaseXSL is executed.



called after the postpaint method of a widget based on WidgetBaseXSL is executed.



called whenever GmlRendererOL creates or destroys its vector layer.


 Next>         Back to the configuration page

  • No labels