[mapguide-users] Bypassing initial view at startup - and adding a layer

gingerbbm stuart.jones at jacobs.com
Thu Sep 4 11:46:02 EDT 2008


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();


-- 
View this message in context: http://n2.nabble.com/RE%3A-Bypassing-initial-view-at-startup-tp790257p839124.html
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list