[fusion-dev] multilevel legend tree with mapserver

klementszabolcs klement at vati.hu
Fri Nov 14 04:11:20 EST 2008


Hi i make multilevel tree in Mapserver/php/LoadMap.php.
when make a mapfile.grp in the same directory where mapfile.map exists,
then the "groups":[] piece in loadmap json result change with the grp 
file content.
the grp file sample:
"groups":[
{   
"groupName":"main","legendLabel":"xxx","uniqueId":"main","displayInLegend":true,"expandInLegend":false,"layerGroupType":"","parentUniqueId":"","parent":"","visible":true,"actuallyVisible":0
  },
  {
 "groupName":"sample","legendLabel":"sample","uniqueId":"sample","displayInLegend":true,"expandInLegend":false,"layerGroupType":"","parentUniqueId":"main","parent":"","visible":true,"actuallyVisible":0
  }]

the change in loadmap.php:
from line 280:

$mapObj->groups = array();
    $aGroups = $oMap->getAllGroupNames();
   
    //multilevel tree
    $groupfile=substr($_REQUEST['mapfile'], 0, 
strpos($_REQUEST['mapfile'], ".")).'.grp';
    if (file_exists($groupfile)) {
      $groupstr=file_get_contents($groupfile);
    }else{
      foreach($aGroups as $groupName) {
          $aLayerIndexes = $oMap->getLayersIndexByGroup($groupName);
          if (count($aLayerIndexes) > 0) {
              array_push($mapObj->groups, 
getGroupObject($oMap->getLayer($aLayerIndexes[0])));
          }
      }
    }
    //tree end
    $retstr=var2json($mapObj);
    if (isset($groupstr)) {
      $retstr=str_replace('"groups":[]',$groupstr,$retstr);
      //echo $groupstr;
    }
   
    echo $retstr;







More information about the fusion-dev mailing list