[mapguide-users] Zoom+select features problem

padmini godavarthi godavarthi.padmini at gmail.com
Wed Mar 10 05:18:33 EST 2010


Hi,
iam using php with mgos 2.1


can  anyboby  plz help me for zoom to feature code for php...
for ex:i have zoom.php (i called this form weblayout as task pane)

i want to enter parcel_id in to text box and in  zoom button click it should
be select and zoomed in the map.
i know mapguide code for this task..(which i have done in .net previously)
but the problem is i don't know php and java script
can u plz guide me by giving outline of code(i mean to say how to call
zoom(),select() in a single button click and how to pass textbox value to
the php code...
i have seen php examples as well as mapguide sample applications.but iam not
getting the exact idea????????

the following are the my code but parcel selection is not working  plz help
me


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
 <script language="javascript">

       function Zoom1(x,y)
	        {
	        var xval=x;
	        var yval=y;

	         parent.parent.mapFrame.ZoomToView(xval, yval, 2000, true);
      }

         function Zoom()
	  	        {

	  	     selectionXml = '<?php echo $selectionXml;?>';
			 parent.parent.mapFrame.SetSelectionXML(selectionXml);


      }
    </script>
<?php
 try
{
   include 'utilityfunctions.php';
$webExtensionsDirectory = 'C:\Program Files\OSGeo\MapGuide\Web\\';

$MapGuideServerDirectory = 'C:\Program Files\OSGeo\MapGuide\Server\\';

$viewerFilesDirectory = $webExtensionsDirectory . 'www\viewerfiles\\';

$schemaDirectory = $MapGuideServerDirectory . 'Schema\\';

$webconfigDirectory = $webExtensionsDirectory . 'www\\';
$webconfigFilePath = $webconfigDirectory . 'webconfig.ini';

MgInitializeWebTier($webconfigFilePath);

      $args =  ($_SERVER['REQUEST_METHOD'] == "POST") ? $_POST : $_GET;
      $sessionId = $args['SESSION'];
      $mapName = $args['MAPNAME'];
       $userInfo = new MgUserInformation($sessionId);
       $siteConnection = new MgSiteConnection();
      $siteConnection->Open($userInfo);

$resourceService =
$siteConnection->CreateService(MgServiceType::ResourceService);

$featureService =
$siteConnection->CreateService(MgServiceType::FeatureService);

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

      $layers = $map->GetLayers();

      $count = $layers->GetCount();
      for ($i = 0; $i < $count; $i++)
      {

        $layer = $layers->GetItem($i);

      }
$layerClassName1 = $layer->GetFeatureClassName();
echo $layerClassName1;
  $FeatureResId = new
MgResourceIdentifier("Library://data/resource.FeatureSource");
$queryOptions = new MgFeatureQueryOptions();
$val="PARCEL";
$val1="44142300003000";
echo $val1;
$query=$val . "=" . $val1;
echo $query;
 $queryOptions->SetFilter($selectionString);
 $featureReader = $featureService->SelectFeatures($FeatureResId,
$layerClassName1, $queryOptions);

          $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 $mapCenterX;
          echo $mapCenterY;

          $selection = new MgSelection($map);

		  $selection->AddFeatures($layer, $featureReader, 1);

		  $selectionXml = $selection->ToXml();



  }
    catch (MgException $e)
    {
      echo "<p><strong>Error:</strong> ";
      echo $e->GetDetails();
      echo "</p>";
    }
    ?>


<html>
<head>
 <title>Zoom Feature</title>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <meta http-equiv="content-script-type" content="text/javascript">
    <meta http-equiv="content-style-type" content="text/css">
    <link href="../styles/globalStyles.css" rel="stylesheet" 
type="text/css">
    <link href="../styles/otherStyles.css" rel="stylesheet" type="text/css">
</head>
<body>
<input type="text" name="id" size="15">
<input type="button" name="button" value="Click" size="10"
onclick="Zoom1(<?php echo $mapCenterX;?>,<?php echo $mapCenterY;?>)">
<input type="button" name="button1" value="Select" size="10"
onclick="Zoom()">

</body>
</html>

1) feature selection is not happing...is there anything wrong in my
code????????
2)i also want to call zoom() and zoom1() functions in a single button click
.how to do it???

regards,
Padmini G.
-- 
View this message in context: http://n2.nabble.com/Zoom-select-features-problem-tp4708107p4708107.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list