[OpenLayers-Users] Custom Toolbar

Andrew Haigh haighaj+ollist at googlemail.com
Thu Apr 15 08:53:39 EDT 2010


OpenLayers 2.9 RC 2

I'm attempting to create a custom tool and toolbar class but I seem to be
running into an issue with the custom toolbar.

Here is my code below

ZoomToAgreementExtent = OpenLayers.Class(OpenLayers.Control, {
    type: OpenLayers.Control.TYPE_BUTTON,
    trigger: function() {
        if (this.map) {
            alert('this is a test');
        }
    },
    CLASS_NAME: "ZoomToAgreementExtent"
});

ApplicationToolbar = OpenLayers.Class(OpenLayers.Control.Panel, {
    initialize: function(options) {
        OpenLayers.Control.Panel.prototype.initialize.apply(this,
[options]);
        this.addControls([
          new OpenLayers.Control.Navigation(),
          new OpenLayers.Control.ZoomBox(),
          new ZoomToAgreementExtent()
        ]);
    },
    draw: function() {
        var div = OpenLayers.Control.Panel.prototype.draw.apply(this,
arguments);
        this.activateControl(this.controls[0]);
        return div;
    }
    CLASS_NAME: "ApplicationToolbar"
});

Then on my map init method I do this:

var appToolbar = new ApplicationToolbar();
map.addControl(appToolbar);

The ZoomToAgreementExtent control seems to work fine but when I try and add
the ApplicationToolbar (which I based on the NavToolbar) I get the following
error in FireBug:

this.initialize is undefined in OpenLayers-2.9-rc2.js on line 117.

I assume that there isn't a bug in the Open Layers library but instead there
is something wrong with my code.

Any ideas?

Thanks

Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100415/b18143be/attachment.html


More information about the Users mailing list