[mapserver-users] Change CLASS Expression using MapScript
Steve Lime
Steve.Lime at dnr.state.mn.us
Mon Oct 12 16:40:09 PDT 2009
Couple of things:
1) you don't need to open/close a layerObj to change it
2) something doesn't make sense in your approach. Are you saving the mapfile somehow with the
changes so that the subsequent WMS call can make use of it? I don't know how the WMS call would
know you mucked with the class otherwise.
Steve
>>> On 10/12/2009 at 6:29 PM, in message
<1255390195922-3811433.post at n2.nabble.com>, Dash <jimlug at co.clackamas.or.us>
wrote:
> Hey there folks,
>
> I am banging my head against this problem for sometime now. I have a
> MapFile that is set up to deliver WMS layers when requested through
> OpenLayers. Within my web page I am trying to change the Class Expression
> (MapScript/PHP). Below is the method I am using to gain access to the Class
> and change the expression. I am performing this before I enter a body tag.
> The body tag has a onload event that fires off the parameters/layers I am
> using within OpenLayers and makes the call to the WMS layers within my
> MapFile. Am I missing something here? I thought since I am declaring the
> expression before I'm displaying the map everything would be ok. I've even
> retrieved the edited expression and it should work. The only thing I can
> imagine is that it has something to do with a WMS setting. Any help would
> be greatly appreciated. Thanks.
>
> <head>
> .
> .
> .
> </head>
>
> <?php
> $situsEnc = $_POST['home'];
> $situs = urldecode($situsEnc);
>
> $map_path="/something/other/than/dirty/socks/wms/";
> $map = ms_newMapObj($map_path."schools.map");
>
> $mafLyr = $map->getLayerByName('maf');
> $mafLyr->open();
> $mafClass = $mafLyr->getClass(0);
> $mafClass->setExpression("('[situs]' = '" . $situs . "')");
> $mafLyr->close();
>
> <body onload=i"nit()">
> <div id="map"></div>
> </body>
More information about the MapServer-users
mailing list