Wednesday, August 27, 2014

GWT, OpenLayers mControl triggers


I'm working with GWT and OpenLayer, and need to activate clicks on a map.

For this I created a mControl.js with the following code:

OpenLayers.Control.mControl = OpenLayers.Class(OpenLayers.Control, {
    defaultHandlerOptions: { },
    initialize: function(options) {
        this.handlerOptions = OpenLayers.Util.extend(this.defaultHandlerOptions, options);
        OpenLayers.Control.prototype.initialize.apply(this, arguments);
        if (options.handlerType=='Polygon')
        this.handler = new OpenLayers.Handler.Polygon(this, {'done': this.trigger}, this.handlerOptions);
        else if (options.handlerType=='Click')
        this.handler = new OpenLayers.Handler.Click(this, {'click': this.trigger }, this.handlerOptions);
        else if (options.handlerType=='Box')
        this.handler = new OpenLayers.Handler.Box(this, {'done': this.trigger }, this.handlerOptions);
    trigger: function(e) {
    var res = null;
if (this.handlerType=='Polygon')
res = e;
        else if (this.handlerType=='Click')
        res =;
        else if (this.handlerType=='Box'){
        if(e.left && e.right && e.bottom &&{
var ll = OpenLayers.Pixel(e.left, e.bottom)); 
var ur = OpenLayers.Pixel(e.right,;
res = new OpenLayers.Bounds(ll.lon,,ur.lon,;
res.transform(new OpenLayers.Projection(,;
    if (this.onTrigger) this.onTrigger(res);

In class have the following methods:

public class mControlImpl {
public static native JSObject create(JSObject paramJSObject) /*-{ 
return new $wnd.OpenLayers.Control.mControl(paramJSObject);

public static native void setOnTrigger(JSObject paramJSObject, mControl control) /*-{ 
  $wnd.OpenLayers.Control.mControl(paramJSObject, control);

My problem is that the setOnTrigger method, gives error: TypeError: this.CLASSNAME is undefined OpenLayers.js: 157

Can somebody help me?

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment