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.

loadXML($layerDefinition);<br />

if (! $domDocument->schemaValidate(<br />

"$schemaDirectory\LayerDefinition-1.0.0.xsd") )<br />

{<br />

echo "ERROR: The new XML document is invalid.<br />

\n.";<br />

return NULL;<br />

}<br />

// Save the new layer definition to the session<br />

// repository<br />

$byte<strong>Source</strong> = new MgByte<strong>Source</strong>($layerDefinition,<br />

strlen($layerDefinition));<br />

$byte<strong>Source</strong>->SetMimeType(MgMimeType::Xml);<br />

$resourceID = new MgResourceIdentifier(<br />

"Session:$mgSessionId//$layerName.LayerDefinition");<br />

$resourceService->SetResource($resourceID,<br />

$byte<strong>Source</strong>->GetReader(), null);<br />

$newLayer = add_layer_resource_to_map($resourceID,<br />

$resourceService, $layerName, $layerLegendLabel,<br />

$map);<br />

return $newLayer;<br />

}<br />

///////////////////////////////////////////////////////////<br />

This function adds a layer resource to a map.<br />

68 | Chapter 4 Modifying Maps and Layers

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

Saved successfully!

Ooh no, something went wrong!