[Chameleon] dynamic map changes

Paul Spencer pspencer at dmsolutions.ca
Wed Mar 30 06:23:49 EST 2005


Rhys,

this can be accomplished in a slightly different way than you might 
first expect :)  The drawing of the map is actually deferred until after 
page load and happens in a script called drawmap.php 
(htdocs/common/wrapper/)

You can insert your script in your index.phtml file after the call to 
CWCInitialize and before the call to CWCExecute to run the query and set 
the extents.

To modify the the output image to include a query, you can save the 
query results into the session directory and drawmap.php will 
automatically load these results and use drawQuery() instead of draw()

for example:

$oApp->CWCInitialize( ... );
// code to find shape index in specified layer
....
// on first loading of map only...
if( $findSuccess ){
     $oMap = new ms_MapObj( $szMapFile );
     $oLayer = $oMap->getLayerByName( $szLayerName );
     $oLayer->queryByIndex( $oMap, $idx, -1 );
     $oMap->saveQuery( getSessionSavePath()."/query_results.qry");
     $oMap->extent = $oLayer->getResult(0)->bounds;
}
$oApp->CWCExecute(...);

Cheers

Paul

Rhys Ickeringill wrote:
> Hi All,
> 
> If I wish dynamically change some map settings before the first drawing of
> the map (but not subsequent ones), what methods of the Chameleon class
> should I override?
> 
> Specifially I wish to do two things dynamically - highlight a specific
> feature via a query and set the map extent to the extent of that feature. I
> assume this will have to happen just after the mapfile has been parsed but
> before the $oMap->draw() gets called (I have yet to trace where this call
> occurs)
> 
> ie. the code should look something like
> 
>     // code to find shape index in specified layer
>     ....
>     // on first loading of map only...
>     if( $findSuccess ){
>         $oMap = new ms_MapObj( $szMapFile );
>         $oLayer = $oMap->getLayerByName( $szLayerName );
>         $oLayer->queryByIndex( $oMap, $idx, -1 );
>         $oMap->extent = $oLayer->getResult(0)->bounds;
>         $oImage = $oMap->draw( );
>         $oLayer->drawQuery( $oImage );
>         }
> 
> Is there somewhere I place this with minimal interuption to the rest of
> Chaemeleon's operations but still get the desired functionality?
> 
> Any suggestions/pointers will be greatly appreciated,
> 
> Rhys
> 
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon
> 


More information about the Chameleon mailing list