Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I set up an openlayers permalink function. I set the code and it shows up. But the URL does not work. Where is I get a link like this:

The only thing that works is the chosen layers. It does not show the correct zoom or boundingbox. What do I need in the code to get this to work? I can not see I have any variables like "lat", "lon" or "zoom". Any examples as how to get this to work? I also would like to put the permalink in the toolbar so that one can copy the URL. I am using ExtJS 2.2. But this is another issue and I have to get the permalink to work first.

I add the permalink like this:

controls: [new OpenLayers.Control.KeyboardDefaults(),new OpenLayers.Control.PanZoomBar(),new OpenLayers.Control.ScaleLine(),
                new OpenLayers.Control.Navigation(),new OpenLayers.Control.Permalink()]

My app.js is here if anyone wants to take a look: The site is running here:


I got this to work this way. Don't know if it was good or bad but it seems to work: I use a function to zoom in to a location and added functionality to just zoom in to the view. I use the OpenLayers.Permalink() function.

        // If URL contains ref. to a location:
        var args = OpenLayers.Util.getParameters();
        if (args.x && args.y) {
            var position = new OpenLayers.LonLat(parseFloat(args.x), parseFloat(args.y));
            map.setCenter(position, 14);
            var xy = map.getViewPortPxFromLonLat(position);
            xy.x = Math.round(xy.x);
            xy.y = Math.round(xy.y);
            info.getInfoForClick({xy: xy});
        } // read the permalink URL
        else if ( && args.lon && args.zoom) {
            var position = new OpenLayers.LonLat(parseFloat(args.lon), parseFloat(;
            map.setCenter(position, parseFloat(args.zoom));
        else {
                map.setCenter(new OpenLayers.LonLat(528277, 7188837), 3);
share|improve this question

It looks like you use GeoExt. There is own permalink mechanism for using within GeoExt. See docs and example.

share|improve this answer
Thanks. I am using Mapfish and Extjs and there are GeoExt components but when I use the GeoExt sample I get errors. Sorry I did not make this solution all by myself so I am a bit confused. When I use the code from the GeoExt docs or example I get error. It does not understand: var permalinkProvider = new GeoExt.state.PermalinkProvider(); Where do I start to look? It seems that the OpenLayers.permalink is accepted but it does not understand the params for zoom,lat,lon. – asle May 24 '12 at 8:25
I see the code in the javascript for "Ext.extend(Ext.state.CookieProvider,Ext.state.Provider....." so it seems I could use that but maybe where exactly to put it in my app.js is the problem? – asle May 24 '12 at 8:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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