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.

function add_layer_resource_to_map($layerResourceID,<br />

$resourceService, $layerName, $layerLegendLabel, &$map)<br />

// Adds a layer defition (which can be stored either in the<br />

// Library or a session repository) to the map.<br />

// Returns the layer.<br />

{<br />

$newLayer = new MgLayer($layerResourceID,<br />

$resourceService);<br />

// Add the new layer to the map's layer collection<br />

$newLayer->SetName($layerName);<br />

$newLayer->SetVisible(true);<br />

$newLayer->SetLegendLabel($layerLegendLabel);<br />

$newLayer->SetDisplayInLegend(true);<br />

$layerCollection = $map->GetLayers();<br />

if (! $layerCollection->Contains($layerName) )<br />

{<br />

// Insert the new layer at position 0 so it is at<br />

// the top of the drawing order<br />

$layerCollection->Insert(0, $newLayer);<br />

}<br />

return $newLayer;<br />

}<br />

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

?><br />

This function adds a layer to a legend’s layer group.<br />

Adding Layers To A Map | 69

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

Saved successfully!

Ooh no, something went wrong!