[mapserver-users] Change CLASS Expression using MapScript

Dash jimlug at co.clackamas.or.us
Mon Oct 12 19:47:45 EDT 2009


Thanks for the quick response.

I'll go ahead and make the appropriate change for the layerObj.  As for the
change of expression with the mapfile, I did not know you had to save the
changes.  I just wanted the expression to be changed based on what a user
selects from a form.

The page that leads up to the map page allows a user to select either
elementary, middle or high schools to display.  Since our GIS layer has
these as attributes I wanted to refrain from specifying these layers
multiple times in the mapfile.  I would rather pass an expression into the
mapfile and display the appropriate level.  I hope this makes sense?  

I had this procedure working before, however, I was never specifiying WMS as
a layer.

Thanks...


Steve Lime wrote:
> 
> 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>
> 
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
> 
> 

-- 
View this message in context: http://n2.nabble.com/Change-CLASS-Expression-using-MapScript-tp3811433p3811491.html
Sent from the Mapserver - User mailing list archive at Nabble.com.


More information about the mapserver-users mailing list