[OpenLayers-Users] Idea/request for extending permalink and argparser

Stephen Woodbridge woodbri at swoodbridge.com
Fri Nov 21 11:36:59 EST 2008


Hello,

I have an idea that might be a useful extension to the Permalink control 
that would allow it to support arbitrary additional parameters. It would 
involve adding a callback to the control creation and adding an 
additional method(s) for setting the additional argument values.

Usage would be something like this:

     var plink = new OpenLayers.Control.Permalink(
          "permalink", base, {}, mycallback);

     map.addControl(plink);

Then when you need to set the arguments you would call:

     plink.setArgs({arg1: val2, arg2: var2, etc});
and/or
     plink.addArgs({arg1: val2, arg2: var2, etc});

This would save the arguments and update the permalinks. All values 
should be simple types (numbers, strings, booleans), therefore you have 
to pre-serialize any complex objects.

And then, when the page is reinstantiated, the argParser would call:

     if (this.callback) {
         this.callback(args);
     }

where this.callback is a reference to mycallback and args is the hash 
object with the name/value pairs for the arguments. It is up to the 
callback to find the args it is interested in, validate them, parse them 
into objects if needed, and do whatever it needs to do with them.

Thoughts?
Anyone up for trying to make a patch for this?

My first attempt at try to extend these controls was a total failure, 
but I think this design is a much simpler and a more general approach 
than what I initially tried to do. Meanwhile, I just got another crisis 
to chase for a few day.

-Steve



More information about the Users mailing list