0

I solved my problem Problems getting openlayers permalink working on how to get the maps view permalink but now I want to put the permalink in the toolbar instead of reloading the page with the permalink. I would like a popup like the one here on stackexchange when you click the "Link" under the post. That pops up a box with the URL selected.

Here is my map: http://babkart.no/ and the toolbar is like this now:

var setToolbarContent = function() {

toolbar.addControl(
        new OpenLayers.Control.ZoomToMaxExtent({
            map: map,
            title: 'Zoom til kartets maksimumsvisning'
        }), {
    iconCls: 'zoomfull',
    toggleGroup: 'map'
}
        );

addSeparator();

toolbar.addControl(
        new OpenLayers.Control.ZoomBox({
            title: 'Zoom inn: klikk i kartet eller bruk venstre museknapp for å tegne en rektangel'
        }), {
    iconCls: 'zoomin',
    toggleGroup: 'map'
}
        );
toolbar.addControl(
        new OpenLayers.Control.ZoomBox({
            out: true,
            title: 'Zoom ut: klikk i kartet eller bruk venstre museknapp for å tegne en rektangel'
        }), {
    iconCls: 'zoomout',
    toggleGroup: 'map'
}
        );
toolbar.addControl(
        new OpenLayers.Control.DragPan({
            isDefault: true,
            title: 'Pan kartet: hold venstre museknapp inne og dra i kartet'
        }), {
    iconCls: 'pan',
    toggleGroup: 'map'
}
        );
toolbar.addControl(
        new OpenLayers.Control.DragPan({
            title: 'Vis info: klikk på et ikon for å vise mere informasjon'
        }), {
    iconCls: 'info',
    toggleGroup: 'map'
}
        );

1 Answer 1

0

i dont know whether this works for you or not, but you can try something to add permalink info to a button tooltip as another DragPan. in the following code you should change iconcls and togglegroup for new button...

     toolbar.addControl(
     var con = map.controls;
     var permalinkInfo;

     for(var a = 0; a< con.length; a++){
        if(con[a].CLASS_NAME == "OpenLayers.Control.Permalink"){
            permalinkInfo = con[a].base
           }
         }

    new OpenLayers.Control.DragPan({
    title: permalinkInfo
    }), {
    iconCls: 'permalink',
    toggleGroup: 'other'
     }
    );

i hope it helps you...

2
  • Thanks but I get this error: Syntax error var con = map.controls;
    – asle
    Commented May 24, 2012 at 13:57
  • What I would really like is to use an Ext messagebox like the "prompt" example her: dev.sencha.com/deploy/ext-4.0.0/examples/message-box/… But I am using ExtJS 2.2. If I could open a box like the the div that opens when you click on "link" under a message here on the forum that would be nice.
    – asle
    Commented May 24, 2012 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.