[Chameleon] Start up layers
Eric Bridger
eric at gomoos.org
Fri Jan 21 16:27:49 EST 2005
I could not get the approach discussed below to work. Not sure why and
I don't have time to really investigate it further now.
In my InitLayers widget e.g. when passing on the command line:
index.phtml?initLayers=layer1+layer2 the widgets
$this->isVarSet('initLayers') returns false, while if
isset($_GET['initLayers']) returns true!? Not sure why.
So my alternative and successful approach was to create a small
invisible InitLayers widget extending CWCWidget with really just a
ParseURL function that does anything. I set the priority last to ensure
the my XMLThemeLegend widget gets processed fist.
$this->mnPriority = PRIORITY_LAST;
In the ParseURL I have:
// Initial Layer selection from GET Query string.
if (isset($_GET['initLayers']))
{
$aInitLayers = explode(" ", $_GET['initLayers']);
foreach( $aInitLayers as $the_layer )
{
$oLayer = $this->moMapObject->oMap->getLayerByName($the_layer);
$oLayer->set("status", MS_ON);
}
}
This is working well for me. The only caveat is that I need to
explicitly set my <form action="index.phtml" method="post"> in my
template which ensures that the $_GET is only set the first time thru.
When I get some more time I will post the whole widget and notes to the
wiki because I think it might be useful.
Eric
On Thu, 2005-01-20 at 15:39, Paul Spencer wrote:
> Eric,
>
> it should be possible to fake the application into turning on certain
> layers as the app starts by passing the correct URL. This is because
> the legend widgets (HTML and XML) use form variables to track layer
> state between page loads. I'm not exactly sure what the syntax would be
> so my suggestion is that you change your form method to GET, load the
> app, set the right layer status, update the page and capture the URL
> that is generated, then eliminate all the pieces that don't have to do
> with layer status and that should be what you need to add to turn layers
> on/off
>
> If you get this to work, I would appreciate a note back to the list so
> we can add it to the tikiwiki for future users
>
> Cheers,
>
> Paul
>
> Eric Bridger wrote:
> > I'd like to be able to start up my application with various layers
> > turned on without using the map file. Ideally with a CGI command line
> > parameter e.g. layers=land+boundaries+etc. In other cases a different
> > set of layers would be sent. Is this possible?
> >
> > What do you think would be the best approach to this.
> >
> > After the initial startup I'm using the XMLThemeLegend widget to control
> > layers.
> >
> > Eric
More information about the Chameleon
mailing list