[mapguide-users] How to debug layer selection troubles?

Kenneth, GEOGRAF A/S ks at geograf.dk
Tue Jul 24 03:16:23 EDT 2007


You should ensure that you actually get results from the query.
Alternatively, you can experiment with the SetSelectionXML function instead.

For debugging, you can modify the size/placement of the hidden frame, so 
it becomes visible.

If you have access to visual studio, you can do runtime debugging 
(stepping, etc) directly in javascript code.
If anyone knows an open source product that allows runtime debugging of 
javascript within a browser, I would like to know it :)

Regards, Kenneth, GEOGRAF A/S


Nico Alberti skrev:
> Hi all,
>
> I am tweaking with the Ajax mapviewer code, trying to insert on the
> Task Area, some forms from whom the user can select features from the
> layers in the map.
>
> While I was able to do this with a polyline, I am not able to do the
> same with a polygon layer. As you can imagine the code is almost
> identical, but in the latter, no feature is selected.
>
> I would appreciate that someone would look at my code, but most of all
> I would like to know how do you deal with script debugging in the
> hidden scriptFrame.  How do you usually debug scripts in that frame?
>
> However here is my code. Thanks for any help you will provide and
> sorry form my bad English.
>
> --------
> <?php
>
> include '../Constants.php';
>
> try
>  {
>        
>         $queryOptions = new MgFeatureQueryOptions();
>        
>        
>        
>        
>         $queryOptions->SetFilter("MACROBACIN='" . $_POST['NomeBacino'] 
> . "'");
>
>         $mgSessionId=$_POST['SESSION'];
>
>         $configFilePath="../../webconfig.ini";
>         MgInitializeWebTier ($configFilePath);
>
>         $userInfo = new MgUserInformation($mgSessionId);
>         $siteConnection = new MgSiteConnection();
>         $siteConnection->Open($userInfo);
>
>         $resourceService =
> $siteConnection->CreateService(MgServiceType::ResourceService);
>         $featureService =
> $siteConnection->CreateService(MgServiceType::FeatureService);
>         $baciniResId = new
> MgResourceIdentifier("Library://BPMS/dati/Data/bacini.FeatureSource");
>
>         $featureReader = $featureService->SelectFeatures($baciniResId,
> "bacini", $queryOptions);
>
>
>         $mapName=urlencode('Mappa');
>
>
>         $map = new MgMap();
>           $map->Open($resourceService, $mapName);
>
>
>         $layer = $map->GetLayers()->GetItem("bacini");
>
>        $selection = new MgSelection($map);
>        $selection->AddFeatures($layer, $featureReader, 0);
>     
>        $selectionXml = $selection->ToXml();
>        
>
> } catch(MgException $e) {
>         echo $e->GetMessage();
>         echo $e->GetDetails();
>
> }
> ?>
> <script language="javascript">
> function OnPageLoad()
> {
> selectionXml = '<?php echo $selectionXml; ?>';
> parent.SetSelectionXML(selectionXml);
> parent.ExecuteCommand(9);  //Zoom to Layer
> }
> </script>
> <body onLoad="OnPageLoad()">
>
>
> </body>
> </html>
>
>
> --------


More information about the mapguide-users mailing list