プログラムで新規画層を作成する最も簡単な方法は、次のとおりです。
画層定義の XML スキーマは、 LayerDefinition-version.xsd スキーマによって定義されます。このスキーマは 『WebApiRef』に記載されています 。このスキーマは Infrastructure Studio の画層エディタの UI によく似ています。この内容は『Studio Help』で説明しています。
この例では、次の処理を行います。
画層を修正する場合は、マップに追加する新規画層だけでなく、既にマップに存在するどの画層についても DOM を使用することができます。他のリソースを修正する場合にも DOM を使用することができます。XML スキーマについては、『 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'; } } // ...
「マップに画層を追加する」に説明するとおり、次にこのページは XML をリソースに保存し、リソースをマップにロードします
他のユーザのマップ内に表示された既存の画層を、それらのマップに影響を与えずに修正するには、次の手順に従います。
詳細は、「マップに画層を追加する」を参照してください。