[OpenLayers-Users] Strategy.Fixed with Parameters Problem

Eric Lemoine eric.lemoine at camptocamp.com
Tue Nov 29 02:20:57 EST 2011


On Monday, November 28, 2011, matth1as <mnick86 at gmail.com> wrote:
> Hi, I have the following Problem: I have a Vector Layer with Strategy
Fixed,
> Protocol HTTP along with some Parameters which are returned by a function:
>
> var opts = {
>  projection: map.displayProjection,
>  strategies: [new OpenLayers.Strategy.Fixed()],
>  protocol: new OpenLayers.Protocol.HTTP({
>  url: "nodes.gojson.php",
>  format: new OpenLayers.Format.GeoJSON({}),
>  params: {'day':getSelectedDay(), 'month':getSelectedMonth(),
> 'year':getSelectedYear()},
>  readWithPOST:true
>  })
>  };
> sundials = new OpenLayers.Layer.Vector("KML", opts);
>
> This works as expected, the POST request contains the parameters (e.g.
> day=1, month=2, year=2011).
>
> A few seconds later, I change day=10,month=12,year=2012 and call
> sundials.refresh() to refresh the vector layer.
>
> But here is the Problem, the new request contains the old values
(1,2,2011)
> ?!

Yes, because your getSelected* functions are called once, when the "params"
object is created. To change params after the creation of the HTTP protocol
do layer.protocol.params.day = 'new day'.

Cheers,

-- 
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/20111129/5bc63e4d/attachment.html


More information about the Users mailing list