[OpenLayers-Users] Idea/request for extending permalink and
argparser
Christopher Schmidt
crschmidt at metacarta.com
Fri Nov 21 12:23:34 EST 2008
On Fri, Nov 21, 2008 at 11:36:59AM -0500, Stephen Woodbridge wrote:
> 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);
The third argument of controls is an options hash. All options hashes in
OpenLayers extend the default/base object properties and methods -- any
'key' in the option hash will override the corresponding key on the
class you're using.
With the existing code, this means that you can do the following:
* Create a new myCreateArgs function:
function myCreateArgs() {
var args =
OpenLayers.Control.Permalink.prototype.createParams.apply(
this, arguments
);
args['myOption'] = myOptionSetting;
}
* Pass this in to the argumets hash, overriding the createParams
function:
var plink = new OpenLayers.Control.Permalink(null, null,
{'createParams': myCreateArgs})
* When something changes, call plink.updateLink();
> And then, when the page is reinstantiated, the argParser would call:
>
> if (this.callback) {
> this.callback(args);
> }
You can already create a customized ArgParser class and pass it to your
Permalink, but I'm not even sure that you should be parsing these things
in the argParser -- just parse them in your init() code instead, no need
to do any modifications or subclassing.
Regards,
--
Christopher Schmidt
MetaCarta
More information about the Users
mailing list