Infrastructure Map Server Forum
Welcome to Autodesk’s Infrastructure Map Server Forums. Share your knowledge, ask questions, and explore popular Infrastructure Map Server topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SOMEBODY CAN HELP ME PLEASE?

1 REPLY 1
Reply
Message 1 of 2
Anonymous
534 Views, 1 Reply

SOMEBODY CAN HELP ME PLEASE?

WHAT IT IS MADE A MISTAKE IN MY CODE?

<body class="AppFrame" onLoad="OnPageLoad()"> 
 <?php 
    include 'common.php'; 
    include 'chamando_mapa.php'; 
    

    $args = ($_SERVER['REQUEST_METHOD'] == "POST")? $_POST : $_GET; 
    $sessionId = $args['SESSION']; 
    $mapName = $args['MAPNAME']; 
    try 
    { 
      MgInitializeWebTier ($configFilePath); 

      $userInfo = new MgUserInformation($sessionId); 
      $siteConnection = new MgSiteConnection(); 
      $siteConnection->Open($userInfo); 
    
      $map = new MgMap($siteConnection); 
      $map->Open($mapName); 
    
     $FeatureResId = new MgResourceIdentifier("Library://GUARUJA/LAYERS/Data/eixos.FeatureSource"); 
     $queryOptions = new MgFeatureQueryOptions(); 
     $queryOptions->SetFilter("DEN_ATU = 'FRANCISCO REBOLO R'"); 
     $layer = $map->GetLayers()->GetItem('eixos'); 
     $layerFeatureClassName = $layer->GetFeatureClassName(); 
     $featureReader = $layer->SelectFeatures($queryOptions); 
     $featureReader=$layer->SelectFeatures($FeatureResId,$layerFeatureClassName,$queryOptions); 

     $layer = $map->GetLayers()->GetItem('eixos'); 
     $selection = new MgSelection($map); 
     $selection->AddFeatures($layer, $featureReader, 9); 
     $selectionXml = $selection->ToXml(); 


} 
catch (MgException $e) 
{ 
echo $e->GetMessage(); 
echo $e->GetDetails(); 


} 
    
    ?> 
     <script language="javascript"> 
    
    function OnPageLoad() 
    { 
      selectionXml = '<?php echo $selectionXml; ?>'; 
      parent.ccc.mapFrame.SetSelectionXML(selectionXml); 
    }     
        
    </script> 
    <body> 
        <input type="button" name="Filtrar" value="Filtrar" onclick="OnPageLoad();" /> 
        <br/> 
<iframe style="width:800px;height:600px" id="ccc" name="ccc" src="/mapguide2010/mapviewerphp/ajaxviewer.php?SESSION=<?php echo $sessionId; ?>&WEBLAYOUT=<?php echo $homologLayout; ?>"> </iframe> 

 

IS GIVING THE FOLLOWING ERROR: An unclassified exception occurred.
E DOES NOT FILTER THE DATA THAT I ASK FOR, AND NOR THE LAYER.
PLEASE SOMEBODY HELPS ME, DOES NOT HAVE MORE FOR WHERE TO RUN.

THANKS
CARLA

1 REPLY 1
Message 2 of 2
gluckett
in reply to: Anonymous

Hi, you don't have to get the Layer multiple times, you can get the Classname and Resource ID from the layer, also you need to save the map at the end:

 

Change this:

 $FeatureResId = new MgResourceIdentifier("Library://GUARUJA/LAYERS/Data/eixos.FeatureSource");
     $queryOptions = new MgFeatureQueryOptions();
     $queryOptions->SetFilter("DEN_ATU = 'FRANCISCO REBOLO R'");
     $layer = $map->GetLayers()->GetItem('eixos');
     $layerFeatureClassName = $layer->GetFeatureClassName();
     $featureReader = $layer->SelectFeatures($queryOptions);
     $featureReader=$layer->SelectFeatures($FeatureResId,$layerFeatureClassName,$queryOptions);

     $layer = $map->GetLayers()->GetItem('eixos');
     $selection = new MgSelection($map);
     $selection->AddFeatures($layer, $featureReader, 9);
     $selectionXml = $selection->ToXml();

 

 

 

To this:

 

 $layer = $map->GetLayers()->GetItem($'eixos');
  $FeatureResId = new MgResourceIdentifier($layer->GetFeatureSourceId());
     $layerFeatureClassName = $layer->GetFeatureClassName();
    
     $queryOptions = new MgFeatureQueryOptions();
     $queryOptions->SetFilter("DEN_ATU = 'FRANCISCO REBOLO R'");
    
     $featureReader=$layer->SelectFeatures($FeatureResId,$layerFeatureClassName,$queryOptions);

     $selection->AddFeatures($layer, $featureReader, 9);
    $selectionXml = $selection->ToXml();
   $selection->Save($resourceService, $map->GetName());

 

regards

gordon

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report