[OpenLayers-Users] Protocol dynamic params

emmexx emmexx at tiscalinet.it
Mon Nov 21 08:48:56 EST 2011


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 want?

Thank you
	maxx


More information about the Users mailing list