MapTools.org

[Chameleon] TreeLegend and XMLThemeParser - making progress

Dave Astolfo dastolfo1@cogeco.ca
Fri, 6 Feb 2004 10:27:42 -0500
Paul,

Thanks for your tips on integrating the dynamic legend. I am making
progress on plugging in a JS-based tree legend into the rendering file.
I have a few challenges.
In order for the JS function to work, I am passing it a list of layer
names that are turned on. It uses those names to determine which boxes
are checked.  

I am trying to make the below code work in this Chameleon 1.1 demo
http://maps.astolfo.com/chameleon_demo/ - (you have seen this already).
I need to figure out if I can call a function similar to what 
is listed below to ge the object that represents the map ($gpoMap). Once
I do that, I need a function that can return the layer names and their
status. The below code that I used in the GMAP demo shows this as
$gpoMap->getAllLayerNames();

When I run it, I get an error " Undefined variable: gpoMap in
c:\mapservertools\cwc2\htdocs\TemplateProcessor.php(207) : eval()'d code
on line 415 "
Doing some basic php testing, If I write "echo $this; ", I get the text
Object returned. So I think I am on the right track, but I am not sure
what the properties of $this are...
I am not sure if what I am trying to do is possible.  Any help is
appreciated.

               --This code is embedded in the rendering file used in the
XMLThemeParser legend.

               <?php
                //create an array that contains all layer names

                $allLayers = $gpoMap->getAllLayerNames();
                
                
                //loop through the array, check to see which layers are
on, and get its name
                for ($i = 0; $i <= count($allLayers) - 1; $i++) {
                  //get the status value of each layer - 1 or 0
		  if (GMapGetStatus($allLayers[$i]) == 1) {
		  //create a delimited list of layer names that are
turned on - they will also be quoted for passing to the JS function
		  $lyrName = $lyrName . "\"" .$allLayers[$i] . "\"" .
","; 
		  }
		}
 
                //trim off the remaining comma from the string
                $lyrName =  substr($lyrName, 0, strlen($str)-1);
                
                //append the array opening and closing brackets to the
string that will be passed to the function
                $lyrName = "[" . $lyrName . "]";   
    		?> 

Thanks,

Dave




This archive was generated by Pipermail.