<%-- Copyright (C) 2004-2011 by Autodesk, Inc. This library is free software; you can redistribute it and/or modify it under the terms of version 2.1 of the GNU Lesser General Public License as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --%> <%@ Page language="c#" %> <%@ Import Namespace="System" %> <%@ Import Namespace="System.Collections.Specialized" %> <%@ Import Namespace="System.IO" %> <%@ Import Namespace="OSGeo.MapGuide" %> Rename layer

Rename Roads Layer

<% sessionId = Request.Params["SESSION"]; mgMapName = Request.Params["MAPNAME"]; try { // Initialize the Web Extensions and connect to the Server using // the Web Extensions session identifier stored in PHP // session state. MapGuideApi.MgInitializeWebTier (Constants.WebConfigPath); MgUserInformation userInfo = new MgUserInformation(sessionId); MgSiteConnection siteConnection = new MgSiteConnection(); siteConnection.Open(userInfo); MgMap map = new MgMap(siteConnection); map.Open(mgMapName); MgLayerCollection layers = map.GetLayers(); MgLayerBase roadLayer = layers.GetItem("Roads"); String roadLabel = roadLayer.GetLegendLabel(); if (roadLabel == "Roads") newLabel = "Streets"; else newLabel = "Roads"; roadLayer.SetLegendLabel(newLabel); // You must save the updated map or the // changes will not be applied // Also be sure to refresh the map on page load. map.Save(); Response.Write("

Layer label has been changed to " + newLabel + ".

"); Response.Write("

Run again

"); } catch (MgLayerNotFoundException e) { Response.Write("

Layer not found

"); } catch (MgObjectNotFoundException e) { Response.Write("

Layer not found

"); } catch (MgException e) { Response.Write(e.GetExceptionMessage()); Response.Write(e.GetDetails()); } %>