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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Mapping Service<br />

The Mapping Service creates eMap and ePlot DWFs.<br />

Generating an eMap DWF requires the DWF version and the URI of the map<br />

agent. Note that the HTTP header must include content length information,<br />

as in the following example.<br />

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

$mapAgentUri =<br />

'http://localhost:8008/mapguide/mapagent/mapagent.exe';<br />

$byteReader = $mappingService->GenerateMap($map, $mapAgentUri,<br />

$dwfVersion);<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 />

An ePlot DWF is designed primarily for offline viewing or printing. It includes<br />

an MgPlotSpecification that defines the page size and margins. It can also<br />

include an optional MgLayout that defines additional components to include<br />

in the plot, like a legend or a custom logo. The layout is based on a print<br />

layout in the repository. For a description of the PrintLayout schema, see the<br />

Map<strong>Guide</strong> Web API Reference.<br />

To create an ePlot DWF with more than one sheet, use an<br />

MgMapPlotCollection, where each item in the collection is an MgMapPlot that<br />

describes a single sheet.<br />

NOTE The map name becomes the sheet name in the multi-plot DWF. Because<br />

each sheet in the DWF must have a unique name, you must create a separate<br />

MgMap object for each sheet in the DWF.<br />

The following example creates a multi-plot DWF with two sheets. The second<br />

sheet displays the same map area as the first, but it adds the title and legend<br />

information from the print layout.<br />

98 | Chapter 7 Custom Output

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

Saved successfully!

Ooh no, something went wrong!