[OpenLayers-Users] Protocol dynamic params

Eric Lemoine eric.lemoine at camptocamp.com
Mon Nov 21 14:17:19 EST 2011


On Monday, November 21, 2011, emmexx <emmexx at tiscalinet.it> wrote:
> I use a vector layer that gets data from the server in geojson format.
> I create the layer like the following.
> Up to now I used only 2 fixed params. Now I would like to use a third
> one, dynamic. On the page there'll be a ckeck and I'd like the 3rd
> parameter to send to the server also this one.
>
> var p3layer = new OpenLayers.Layer.Vector("mylayer",
>        {
>                strategies: [strategy1, strategy2],
>                protocol: new OpenLayers.Protocol.HTTP({
>                        url: path,
>                        params: {
>                                'l1': 'myparameter',
>                                'id': 'another parameter',
>                                'adb': ???
>                                },
>                                format: new OpenLayers.Format.GeoJSON()
>                        }),
>                and so on
>
>
> I tried using a function like the following but it didn't work:
>
> function getadb()
> {
>        return something;
> }
>
> var p3layer = new OpenLayers.Layer.Vector("mylayer",
>        {
> ...
>                        params: {
>                                'l1': 'myparameter',
>                                'id': 'another parameter',
>                                'adb': getadb()
>                                },
>
> What is the correct way to get what I

You can do layer.protocol.params.adb = "value";

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20111121/dc4e1090/attachment.html


More information about the Users mailing list