[Chameleon] date filter

Jason Fournier jfournier at dmsolutions.ca
Wed Nov 2 09:32:32 EST 2005


Dirk,

Three shouldn't be anything else you need to set - you should be able to 
do the following:

     $oMap = $oApp->moMapSession->oMap;

     $oLayer = @$oMap->getLayerByName( 'LAYERNAME' );
     $oLayer->set( 'status', MS_ON );

Note that, according to our example below, tis should happen in the 
CWCProcessURL function.  Setting status before this point in the 
initialization file will (most likely) result in an unaffected layer.

This didn't work?  Instead of using set can you echo out some attributes 
of the layer (eg, $oLayer->name) ?

Best Regards,
Jason



Dirk Jesko wrote:
> Dear Jason,
> 
> I was looking for such a solution too. Thanks.
> 
> Now I have another question: Is it also possible to change the status of 
> a layer at this point? I would like to activate/deactivate a layer based 
> on the value of some form field. I tried to set the value of the layer's 
> status field to MS_ON, but it did not work. Is there something else 
> inside Chameleon that needs to be set, if a layer should be 
> activated/deactivated?
> 
> Regards,
> Dirk
> 
> 
> 
> Jason Fournier wrote:
> 
>> Danna,
>>
>> If I understand correctly I think one way to approach this is to add 
>> custom code in index.phtml handle the layer selection process.  In 
>> your index.phtml you have something like the following:
>>
>> class SampleApp extends Chameleon
>> {
>>
>>     function SampleApp()
>>     {
>>         parent::Chameleon();
>>         $this->moMapSession = new MapSession_RW;
>>         $this->moMapSession->setTempDir( getSessionSavePath());
>>     }
>>
>>     function CWCProcessURL(&$oHTTPFormVars)
>>     {
>>         $bRes =  parent::CWCProcessURL($oHTTPFormVars);
>>         // include any kind of execute processing here ...
>>         return $bRes;
>>     }
>>
>> }
>>
>> The function CWCProcessURL (which I don't think is there by default) 
>> is where you can execute PHP MapScript to affect the state of the 
>> current session mapfile (after $bRes is declared and before $bRes is 
>> returned).  So, for instance, you can get the value of your dropdown, 
>> cycle through the mapfile layers, and perform whichever action you 
>> deem necessary on that layer (eg, visibility, expression, add classes, 
>> etc):
>>
>> $value = $_REQUEST['dropdown'];
>> if( $value == 1990 )
>> {
>>         $oMap = $oApp->moMapSession->oMap;
>>         $nMapLayers = $oMap->numlayers;
>>         for($i=0;$i<$nMapLayers;$i++)
>>         {
>>             $oLayer = $oMap->getLayer($i);
>>             //etc etc
>>         }
>> }
>>
>> Replace or modify the above code with your own.  You may want to keep 
>> an array of layers to turn on for a given dropdown value then write 
>> some generic code to handle it - would save you time in the long run.
>>
>> Is this what you were going after?
>>
>> Best Regards,
>> Jason
>>
>>
>>
>>
>> Danna Dowdy wrote:
>>
>>> I have found where I can use set FILTER in the map file dynamically 
>>> using a form or a url variable but am still not sure how to get those 
>>> variables passed from chameleon??
>>>
>>> Danna Dowdy wrote:
>>>
>>>> I am working on a basic mapping application that currently displays 
>>>> data from a spatial database based on variable groupings.  I have 
>>>> individual views set up for each individual layer.  I would like to 
>>>> add a drop down menu somewhere on the interface so that the user 
>>>> could select a year and plot whatever layers are chosen for that 
>>>> particular year.  The date field is in the database.  Could someone 
>>>> point me in the right direction of how to do this?
>>>> _______________________________________________
>>>> Chameleon mailing list
>>>> Chameleon at lists.maptools.org
>>>> http://lists.maptools.org/mailman/listinfo/chameleon
>>>>
>>>
>>> _______________________________________________
>>> Chameleon mailing list
>>> Chameleon at lists.maptools.org
>>> http://lists.maptools.org/mailman/listinfo/chameleon
>>>
>>
> 
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon
> 

-- 
________________________
Jason Fournier

DM Solutions Group Inc.
jfournier at dmsolutions.ca
www.dmsolutions.ca
613.565.5056 x18


More information about the Chameleon mailing list