The easiest way to programmatically create new layers is to
The XML schema for layer definitions is defined by the LayerDefinition-version.xsd schema, which is documented in the WebApiRef . This schema closely parallels the UI in Infrastructure Studio’s Layer Editor, as described in the Studio Help.
This example
You can use the DOM to modify any layers, including ones that already exist in the map, not just new layers that you are adding to the map. You can also use the DOM to modify other resources; the XML schemas are described in the WebApiRef .
// (initialization etc. not shown here) // Open the map $map = new MgMap(); $map->Open($resourceService, $mapName); // --------------------------------------------------// // Load a layer from XML, and use the DOM to change it // Load the prototype layer definition into // a PHP DOM object. $domDocument = DOMDocument::load('RecentlyBuilt.LayerDefinition'); if ($domDocument == NULL) { echo "The layer definition 'RecentlyBuilt.LayerDefinition' could not be found.<BR>\n"; return; } // Change the filter $xpath = new DOMXPath($domDocument); $query = '//AreaRule/Filter'; // Get a list of all the <AreaRule><Filter> elements in // the XML. $nodes = $xpath->query($query); // Find the correct node and change it foreach ($nodes as $node ) { if ($node->nodeValue == 'YRBUILT > 1950') { $node->nodeValue = 'YRBUILT > 1980'; } } // Change the legend label $query = '//LegendLabel'; // Get a list of all the <LegendLabel> elements in the // XML. $nodes = $xpath->query($query); // Find the correct node and change it foreach ($nodes as $node ) { if ($node->nodeValue == 'Built after 1950') { $node->nodeValue = 'Built after 1980'; } } // ...
The page then goes on to save the XML to a resource and loads that resource into the map, as described in Adding Layers To A Map.
If you wish to modify an existing layer that is visible in other users’ maps, without affecting those maps: