Developer's Guide - MapGuide Open Source - OSGeo
Developer's Guide - MapGuide Open Source - OSGeo
Developer's Guide - MapGuide Open Source - OSGeo
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
(initialization etc. not shown here)<br />
// <strong>Open</strong> the map<br />
$map = new MgMap();<br />
$map-><strong>Open</strong>($resourceService, 'Sheboygan');<br />
// --------------------------------------------------//<br />
// Load a layer from XML, and use the DOM to change it<br />
// Load the prototype layer definition into<br />
// a PHP DOM object.<br />
$domDocument =<br />
DOMDocument::load('RecentlyBuilt.LayerDefinition');<br />
if ($domDocument == NULL)<br />
{<br />
echo "The layer definition<br />
'RecentlyBuilt.LayerDefinition' could not be<br />
found.\n";<br />
return;<br />
}<br />
// Change the filter<br />
$xpath = new DOMXPath($domDocument);<br />
$query = '//AreaRule/Filter';<br />
// Get a list of all the elements in<br />
// the XML.<br />
$nodes = $xpath->query($query);<br />
// Find the correct node and change it<br />
foreach ($nodes as $node )<br />
{<br />
if ($node->nodeValue == 'YRBUILT > 1950')<br />
{<br />
$node->nodeValue = 'YRBUILT > 1980';<br />
}<br />
}<br />
// Change the legend label<br />
$query = '//LegendLabel';<br />
// Get a list of all the elements in the<br />
// XML.<br />
$nodes = $xpath->query($query);<br />
// Find the correct node and change it<br />
foreach ($nodes as $node )<br />
{<br />
if ($node->nodeValue == 'Built after 1950')<br />
{<br />
$node->nodeValue = 'Built after 1980';<br />
}<br />
58 | Chapter 4 Modifying Maps and Layers