[Chameleon] swapping .map files in index.html
Paul Spencer
pspencer at dmsolutions.ca
Tue Aug 2 17:08:35 EDT 2005
Kevin,
the basic problem here is that Chameleon thinks it is way smarter than
you and is actively working against you :> If you do not need to
transfer any session-related information when changing maps then the
safest way to do this would be to start a new session. However, that
wouldn't necessarily be the best way since this would create some
additional (and possibly significant) overhead.
What you really need to do is to clear out form variables posted from
the previous page. To do this, you would need to detect that the user
had selected a new map file at the top of your index.phtml and clear the
$_GET/$_POST/$_FORM variables of all values EXCEPT those you need to
keep (this may take some experimentation, but from experience I would
suggest that you keep any session id (sid/SID) and language)
ie:
$sid = $_GET['sid'];
$_GET = array( 'sid' => $sid );
Also, as a general comment you should not be putting HTML into the
output from index.phtml. That HTML should go into your template. To
replicate the functionality you are looking for, you would create a
variable:
$options = '';
and for every echo, you would add the value to $options instead.
Then:
$oApp->CWCInitialize();
$oApp->setVar( 'options', $options );
and in your template, you would put:
<select name="Project_Selection">[$options|$]</select>
<input type="submit" value="Go!">
Cheers
Paul
kgrootendorst at baird.com wrote:
>
> Hello,
> I'm building an application where a user can 'switch' between .map files
> using a dropdown/combo box, and use the same 'template.html' file.
>
> I've modified the index.html to accept user input via a combo box (user
> selects what project .map file they want to view), and have the .map
> load in the template.
> I can view the first project without any problem. However, when I
> select the second project, it loads fine, but it seems to maintain the
> coordinate system and extents of the first project.
> Since they have 2 very different coordinate systems and extents, I'm
> unable to view the second project.
>
> Any body have any suggestions? I feel it has to do with the section
> around $oApp = new SampleApp();, where the app is made. Maybe these
> need to be reset somehow?
> Below is my index.phtml file.
> Thanks in advance.
>
> <html>
> <head>
> <script language="javascript">
> window.resizeTo(1028,768);
> </script>
> </head>
> <body>
> <?php
>
> //set up combo box and retain user selection
> $values = array('Barbados','Pelee');
> echo '
> <form method="post" action="'.$_SERVER['PHP_SELF'].'">
> <select name="Project_Selection">';
> for($x = 0; $x < count($values); $x++)
> {
> // write "selected" if the value matches the one posted
> if($values[$x] == $_POST['Project_Selection'])
> {
> $selected = ' selected';
> }else{
> $selected = '';
> }
> // print the option
> echo '
> <option
> value="'.$values[$x].'"'.$selected.'>'.$values[$x].'</option>';
> }
> echo '
> </select>
> <input type="submit" value="Go!"> ';
> //</form>';
>
>
>
> /*
> * this is a sample of a minimal application script required to
> * get a chameleon application running with a template and a
> * local map file. Most applications should actually just
> * copy this file and modify the template and mapfile
> * parts and should not need to do a lot more here.
> */
>
> $project_choice = $_POST['Project_Selection'];
>
> //echo "$project_choice";
>
> $gszAppPath = dirname(__FILE__);
>
> include( "../../htdocs/chameleon.php" );
>
> $szTemplate = dirname(__FILE__)."/GIS_template.html";
> //$szTemplate = dirname(__FILE__)."/$project_choice.html";
> $szMapFile = dirname(__FILE__)."/../map/$project_choice.map";
>
> class SampleApp extends Chameleon
> {
> function SampleApp()
> {
> parent::Chameleon();
> $this->moMapSession = new MapSession_RW;
> $this->moMapSession->setTempDir( getSessionSavePath());
> }
> }
>
> // add some sort of reset?
>
> $oApp = new SampleApp();
> $oApp->registerSkin( 'skins/sample' );
> $oApp->CWCInitialize( $szTemplate, $szMapFile );
> $oApp->CWCExecute();
>
> echo '</form>';
> ?>
> </body>
> </html>
>
>
> Using Chameleon 2.2, MapServer 4.4, PHP 4.3.7
>
> Kevin
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon
--
+-----------------------------------------------------------------+
|Paul Spencer pspencer at dmsolutions.ca |
+-----------------------------------------------------------------+
|Applications & Software Development |
|DM Solutions Group Inc http://www.dmsolutions.ca/|
+-----------------------------------------------------------------+
More information about the Chameleon
mailing list