Just glad I could help :).
I have put up your code in the comunity code samples (I hope you don't
mind):
http://trac.osgeo.org/mapguide/wiki/CodeSamples/PHP/AddLayerToInitialMap
Regards, Kenneth Skovhede, GEOGRAF A/S
gingerbbm skrev:
Well, hooray, and thanks for all your help. I'd like to buy you a beer ;)
Here's a snippet that might be useful for others:
// Build a string pointing to the new layer in the Session
$rlLayerResourceId = "Session:$sessionId//$layerName.LayerDefinition";
// Read the XML of the Library Map Definition
$mdReader = $resourceService->GetResourceContent($mdResourceId);
$mdXml = $mdReader->ToString();
$mdDomDoc = DOMDocument::loadXML($mdXml);
// Create the MapLayer XML nodeset in the first position
$targetNode = $mdDomDoc->getElementsByTagName("MapLayer")->item(0);
$newNode = $targetNode->parentNode->insertBefore(new DOMElement("MapLayer"),
$targetNode);
$newNode->appendChild($mdDomDoc->createElement("Name", $layerName));
$newNode->appendChild($mdDomDoc->createElement("ResourceId",
$rlLayerResourceId));
$newNode->appendChild($mdDomDoc->createElement("Selectable", "false"));
$newNode->appendChild($mdDomDoc->createElement("ShowInLegend", "false"));
$newNode->appendChild($mdDomDoc->createElement("LegendLabel"));
$newNode->appendChild($mdDomDoc->createElement("ExpandInLegend", "false"));
$newNode->appendChild($mdDomDoc->createElement("Visible", "true"));
$newNode->appendChild($mdDomDoc->createElement("Group"));
// Write the XML out to form the Session Map Definition
$mdUpdatedXml = $mdDomDoc->saveXML();
_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users