Open($userInfo);
// If any parcels have been selected, recenter the image on the first selected parcel.
if ($xmlSelection != '')
{
$resourceService = $siteConnection->CreateService(MgServiceType::ResourceService);
$featureService = $siteConnection->CreateService(MgServiceType::FeatureService);
$queryOptions = new MgFeatureQueryOptions();
$map = new MgMap();
$map->Open($resourceService, $mapName);
$selection = new MgSelection($map, $xmlSelection);
$layers = $selection->GetLayers();
if ($layers)
{
for ($i = 0; $i < $layers->GetCount(); $i++)
{
// Only check selected features in the Parcels layer.
$layer = $layers->GetItem($i);
if ($layer && $layer->GetName() == 'Parcels')
{
// Create a filter containing the IDs of the selected features on this layer
$layerClassName = $layer->GetFeatureClassName();
$selectionString = $selection->GenerateFilter($layer, $layerClassName);
// Get the feature resource for the selected layer
$layerFeatureId = $layer->GetFeatureSourceId();
$layerFeatureResource = new MgResourceIdentifier($layerFeatureId);
// Apply the filter to the feature resource for the selected layer. This returns
// an MgFeatureReader of all the selected features.
$queryOptions->SetFilter($selectionString);
$featureReader = $featureService->SelectFeatures($layerFeatureResource, $layerClassName, $queryOptions);
// Create the report details using the first selected parcel. Position the image so the
// centroid of the selected parcel is in the center of the map.
$featureReader->ReadNext();
$featureAgfGeometry = $featureReader->GetGeometry('SHPGEOM');
$agfReaderWriter = new MgAgfReaderWriter();
$featureGeometry = $agfReaderWriter->Read($featureAgfGeometry);
$centroid = $featureGeometry->GetCentroid();
$mapCenterX = $centroid->GetCoordinate()->GetX();
$mapCenterY = $centroid->GetCoordinate()->GetY();
$owner = $featureReader->GetString('RNAME');
$address = $featureReader->GetString('RPROPAD');
$billingAddress = $featureReader->GetString('RBILAD');
$description = $featureReader->GetString('RLDESCR1') . '
' . $featureReader->GetString('RLDESCR2') . '
' . $featureReader->GetString('RLDESCR3') . '
';
}
}
}
}
}
catch (MgException $e)
{
echo '
' . $e->GetExceptionMessage() . '
'; echo '' . $e->GetDetails() . '
'; } $selectionEncoded = urlencode($xmlSelection); $imageUrl = "createmapimage.php?SESSION=$sessionId&SELECTION=$selectionEncoded&MAPNAME=$mapName&SCALE=$mapScale" . "&HEIGHT=$imageHeight&WIDTH=$imageWidth&CENTERX=$mapCenterX&CENTERY=$mapCenterY"; ?>
\n";
echo "Address: $address
\n";
echo "Billing Address: $billingAddress
\n";
echo "Description: $description
\n";
}
?>