Help developing a zoom to function using flexible forms

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Help developing a zoom to function using flexible forms

Leonardo Parra
Hi All,

I'm developing an application in php that is linked to a mapguide site that uses flexible forms. Users call a page from Mapguide that displays a table with all the records of the layer.  Users apply different filters to the table and then click on a button that calculates the coordinates of the feature, selects it and zooms into it.  In theory it should work, but I'm having problems selecting and zooming into the feature.

Here is the code I have so far:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">

<body class="AppFrame" onLoad="OnPageLoad()">

Select features

        'C:\Program Files\Autodesk\MapGuideEnterprise2011\WebServerExtensions\www\fusion\layers\MapGuide\php\common.php';
    $configFilePath = 'C:\Program Files\Autodesk\MapGuideEnterprise2011\WebServerExtensions\www\webconfig.ini';
        //capture sessionId and MapName from the URL
    $args = ($_SERVER['REQUEST_METHOD'] == "POST")? $_POST : $_GET;
    $sessionId = $args['SESSION'];
    $mapName = $args['MAPNAME'];
      // Initialize the Web Extensions and connect to the Server
      // using the Web Extensions session identifier
      $userInfo = new MgUserInformation($sessionId);
      $siteConnection = new MgSiteConnection();
          $resourceService = $siteConnection->CreateService(0);
      $featureService = $siteConnection->CreateService(2);

          $map = new MgMap($siteConnection);
      $selection = new MgSelection($map);
      $selection->Open($resourceService, $mapName);
          echo "SessionID:".$sessionId;
      echo "MapName:".$mapName;  
         //Create Filter
         $queryOptions = new MgFeatureQueryOptions();
         $queryOptions->SetFilter("PLOT_ID = 'F-I-32'");
     //Capture Layer and apply filter to it
         $layer = $map->GetLayers()->GetItem('plots');
         $layerFeatureId = $layer->GetFeatureSourceId();
     $layerFeatureResource = new MgResourceIdentifier($layerFeatureId);
         $layerClassName = $layer->GetFeatureClassName();
     $featureReader = $featureService->SelectFeatures($layerFeatureResource, $layerClassName, $queryOptions);

         //Capture geometry and modify selection
         echo "Number of features:".$featureReader->GetPropertyCount();
         while ($featureReader->ReadNext())
                $featureAgfGeometry = $featureReader->GetGeometry('Geometry');
        $agfReaderWriter = new MgAgfReaderWriter();
        $featureGeometry = $agfReaderWriter->Read($featureAgfGeometry);
        $centroid = $featureGeometry->GetCentroid();
        $mapCenterX = $centroid->GetCoordinate()->GetX();
        $mapCenterY = $centroid->GetCoordinate()->GetY();
                echo "X:".$mapCenterX;
                echo "Y:".$mapCenterY;
                echo "PlotID:".$featureReader->GetString('PLOT_ID');
        $selection->AddFeatures($layer, $featureReader, 0);
                $selectionXml = $selection->ToXml();
                $selection->Save($resourceService, $map->GetName());
catch (MgException $e)
echo $e->GetMessage();
echo $e->GetDetails();
<script language="javascript"> // Emit this function and assocate it with the onL // for the page so that it gets executed when this // loads in the browser. The function calls the // SetSelectionXML method on the Viewer Frame, whi // the current selection on the viewer and the ser function OnPageLoad() { //selectionXml = '<?php echo $selection; ?>'; //parent.parent.SetSelection(selectionXml); parent.parent.ZoomToView(<?php echo $mapCenterX; ?>,<?php echo $mapCenterY; ?>,500); } </script>
No idea how to make it work with flexible forms.  I'm using mapguide enterprise 2011 and php.  Any help would be greatly appreciated.