Also,

you could concentrate on your css styles. I really don't understand them, but they have something to do with the functioning. If I add 'ItemInactive' into your style in Firebug, the button works. Maybe *someone could explain* this button thing to us who don't get it. I have been using the following styles and activating/deactivating my buttons by demand.

    .olControlPanel div {
        display:block;
        width:  24px;
        height: 24px;
        margin: 5px;
        background-color:red;
        position: absolute;
        top: 100px;
        left: 10px;
        }

    .olControlPanel .infoItemActive  {
        background-color: green;
        background-image: url("./OpenLayers-2.7/info_on.png");
        position: absolute;
        top: 140px;
        left: 10px;
        }

    .olControlPanel .infoItemInactive {
        background-color: blue;
        background-image: url("./OpenLayers-2.7/info_off.png");
        position: absolute;
        top: 140px;
        left: 10px;
        }

Of course you have to change the displayClass ( Mine is 'info' in this example.) This cretes two-state button (different image when on and off).

- mika -

Arnd Wippermann kirjoitti:
Hi,

Perhaps you have to activate the control:
panel.activateControl(button);

Arnd Wippermann
 

-----Ursprüngliche Nachricht-----
Von: users-boun...@openlayers.org [mailto:users-boun...@openlayers.org] Im
Auftrag von JuergenL
Gesendet: Dienstag, 3. Februar 2009 19:56
An: users@openlayers.org
Betreff: [OpenLayers-Users] Problem with OpenLayers.Control.Button

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
_______________________________________________
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users

_______________________________________________
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users
  
_______________________________________________
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users

Reply via email to