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
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