[OpenLayers-Users] Problem with OpenLayers.Control.Button

JuergenL osm at albspotter.org
Tue Feb 3 13:55:42 EST 2009


Hi,

I'm new to OpenLayers and I try to add my own button to OpenLayers
that calls a JavaScript function when clicked. The button is visible
but nothing happens when I click on it.

That's how I define the button:

            var panel = new OpenLayers.Control.Panel();
            var button = new OpenLayers.Control.Button({displayClass:
"addMarkerBtn", trigger: addMarker});
            panel.addControls([button]);
            map.addControl(panel);

And the function addMarker:

        addMarker = function() {
            alert('test');
        }

I also tried

        function addMarker() {
            alert('test');
        }

Here is a complete test page: http://albspotter.org/osm/test.php

Can anyone tell why this doesn't work?

Thanks in advance
Juergen



More information about the Users mailing list