14.01.2013 Views

Developer's Guide - MapGuide Open Source - OSGeo

Developer's Guide - MapGuide Open Source - OSGeo

Developer's Guide - MapGuide Open Source - OSGeo

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

$dwfVersion = new MgDwfVersion("6.01", "1.2");<br />

$plotSpec = new MgPlotSpecification(8.5, 11,<br />

MgPageUnitsType::Inches);<br />

$plotSpec->SetMargins(0.5, 0.5, 0.5, 0.5);<br />

$plotCollection = new MgMapPlotCollection();<br />

$plot1 = new MgMapPlot($map, $plotSpec, $layout);<br />

$plotCollection->Add($plot1);<br />

// Create a second map for the second sheet in the DWF. This<br />

// second map uses the print layout<br />

// to display a page title and legend.<br />

$map2 = new MgMap();<br />

$map2->Create($resourceService, $map->GetMapDefinition(),<br />

'Sheet 2');<br />

$layoutRes = new MgResourceIdentifier(<br />

"Library://Samples/Sheboygan/Layouts/SheboyganMap.PrintLayout");<br />

$layout = new MgLayout($layoutRes, "City of Sheboygan",<br />

MgPageUnitsType::Inches);<br />

$plot2 = new MgMapPlot($map2,<br />

$map->GetViewCenter()->GetCoordinate(), $map->GetViewScale(),<br />

$plotSpec, $layout);<br />

$plotCollection->Add($plot2);<br />

$byteReader = $mappingService-><br />

GenerateMultiPlot($plotCollection, $dwfVersion);<br />

// Now output the resulting DWF.<br />

$outputBuffer = '';<br />

$buffer = '';<br />

while ($byteReader->Read($buffer, 50000) != 0)<br />

{<br />

$outputBuffer .= $buffer;<br />

}<br />

header('Content-Type: ' . $byteReader->GetMimeType());<br />

header('Content-Length: ' . strlen($outputBuffer));<br />

echo $outputBuffer;<br />

Mapping Service | 99

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!