Open($userInfo);
// Create an instance of ResourceService and use that to open the
// current map instance stored in session state.
$resourceService = $siteConnection->CreateService(MgServiceType::ResourceService);
$map = new MgMap();
$map->Open($resourceService, $mapName);
$mappingService = $siteConnection->CreateService(MgServiceType::MappingService);
$dwfVersion = new MgDwfVersion("6.01", "1.2");
$plotSpec = new MgPlotSpecification(8.5, 11, MgPageUnitsType::Inches);
$plotSpec->SetMargins(0.5, 0.5, 0.5, 0.5);
$layout = null;
$layoutRes = new MgResourceIdentifier("Library://Samples/Sheboygan/Layouts/SheboyganMap.PrintLayout");
$layout = new MgLayout($layoutRes, "City of Sheboygan", MgPageUnitsType::Inches);
$plotCollection = new MgMapPlotCollection();
$plot1 = new MgMapPlot($map, $plotSpec, $layout);
$plot1->SetCenterAndScale($map->GetViewCenter()->GetCoordinate(), $map->GetViewScale() * 2);
$plotCollection->Add($plot1);
// Create a second map for the second sheet in the DWF. This second sheet uses the print layout
// to display a page title and legend.
$map2 = new MgMap();
$map2->Create($resourceService, $map->GetMapDefinition(), 'Sheet 2');
$plot2 = new MgMapPlot($map2, $plotSpec, $layout);
$plot2->SetCenterAndScale($map->GetViewCenter()->GetCoordinate(), $map->GetViewScale());
// $plot2 = new MgMapPlot($map2, $map->GetViewCenter()->GetCoordinate(), $map->GetViewScale(), $plotSpec, $layout);
$plotCollection->Add($plot2);
$byteReader = $mappingService->GenerateMultiPlot($plotCollection, $dwfVersion);
// Now output the resulting DWF.
$outputBuffer = '';
$buffer = '';
while ($byteReader->Read($buffer, 50000) != 0)
{
$outputBuffer .= $buffer;
}
header('Content-Type: ' . $byteReader->GetMimeType());
header('Content-Length: ' . strlen($outputBuffer));
echo $outputBuffer;
}
catch (MgException $e)
{
$result = $e->GetExceptionMessage() . "
" . $e->GetDetails();
header('Content-Type: text/html');
header('Content-Length: ' . strlen($result));
echo $result;
}
?>