[mapguide-users] viewing satellite map image

François Van Der Biest francois.van-der-biest at onf.fr
Fri Nov 3 08:29:08 EST 2006


Jason Birch a écrit :
> If you have the satellite images...
>  
> The easiest way would be to make your map contain both the normal and the satellite images as layer groups.  Make neither of them visible in the legend.  Define the map with the normal layergroup enabled and the satellite image layer group disabled.  
>  
>   

Here's some sample PHP code I wrote to toggle between two rasters called 
scan25 and bdortho, contained in base layer groups respectively called 
base_scan25 and base_bdortho.
It is indeed being called by a button I created with Studio, and it 
loads in the ScriptFrame.

You just have to adapt the paths so that they match with your 
configuration !
In 5 minutes, you're done ...

F.

<html>
<head>
 <meta content="text/html; charset=iso8859-1" http-equiv="content-type">

<script language="javascript" type="text/javascript">
var initTimer = setInterval(demarrage, 200);
function demarrage() {
       try {
               if(parent.GetMapFrame().mapInit) {
                       clearInterval(initTimer);
                       parent.GetMapFrame().Refresh();
               }
       }
       catch(Exception) {}
}
</script>

</head>

<body onLoad="demarrage();">

<?php
$mgSessionId = ($_SERVER['REQUEST_METHOD'] == "POST")?
$_POST['SESSION']: $_GET['SESSION'];
$mapName = ($_SERVER['REQUEST_METHOD'] == "POST")? $_POST['MAPNAME']:
$_GET['MAPNAME'];

//Define some common locations
$installDir ='C:\Program Files\Autodesk\MapGuideEnterpr
ise2007\\';
$extensionsDir = $installDir . 'WebServerExtensions\www\\';
$viewerDir = $extensionsDir . 'phpviewersample\\';

include $viewerDir . 'appconstants.php';

try{
       //Basic initialization needs to be done every time.
       MgInitializeWebTier("$extensionsDir\webconfig.ini");

       //Get the user information using the session id,
       //and set up a connection to the site server.
       $userInfo = new MgUserInformation($mgSessionId);
       $siteConnection = new MgSiteConnection();
       $siteConnection->Open($userInfo);

       //Get an instance of the required service(s).
       $resourceService =
$siteConnection->CreateService(MgServiceType::ResourceService);

       $map = new MgMap();
       $map->Open($resourceService, $mapName);

       $layerGroupCollections=$map->GetLayerGroups();

      
 $layerBaseGroup_scan25=$layerGroupCollections->GetItem('base_scan25');
      
 $layerBaseGroup_bdortho=$layerGroupCollections->GetItem('base_bdortho');

       if ($layerBaseGroup_scan25->isVisible()) {
               //echo "On retire le scan25 et on ajoute la bdortho";
               $layerBaseGroup_scan25->SetVisible(false);
               $layerBaseGroup_scan25->SetDisplayInLegend(false);
               $layerBaseGroup_bdortho->SetVisible(true);
               //$layerBaseGroup_bdortho->SetExpandInLegend(true);  // 
this function does not exist yet
               $layerBaseGroup_bdortho->SetLegendLabel('Fond Scan25');
               $layerBaseGroup_bdortho->SetDisplayInLegend(true);
       }
       else {
               //echo "On retire la bdortho et on ajoute le scan25";
               $layerBaseGroup_bdortho->SetVisible(false);
               $layerBaseGroup_bdortho->SetDisplayInLegend(false);
               $layerBaseGroup_scan25->SetVisible(true);
               //$layerBaseGroup_scan25->SetExpandInLegend(true); // 
this function does not exist yet
               $layerBaseGroup_scan25->SetLegendLabel('Fond Bdortho');
               $layerBaseGroup_scan25->SetDisplayInLegend(true);
       }

       $map->Save($resourceService);

}
catch (MgException $e){
       echo "ERROR: " . $e->GetMessage() . "<br />";
       echo $e->GetStackTrace() . "<br />";
}
?>
</body>
</html>





More information about the Mapguide_users mailing list