[mapguide-commits] r6232 - in trunk/MgDev/Doc/samples/dotnetsamples: . analyzing_features common modifying_maps_and_layers

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Nov 17 07:00:21 EST 2011


Author: jng
Date: 2011-11-17 04:00:21 -0800 (Thu, 17 Nov 2011)
New Revision: 6232

Added:
   trunk/MgDev/Doc/samples/dotnetsamples/analyzing_features/
   trunk/MgDev/Doc/samples/dotnetsamples/analyzing_features/bufferlayerdefinition.xml
   trunk/MgDev/Doc/samples/dotnetsamples/analyzing_features/parcelmarker.xml
   trunk/MgDev/Doc/samples/dotnetsamples/common/mapinfo.aspx
   trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/
   trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/RecentlyBuilt.LayerDefinition
   trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/change_layers_via_dom.aspx
   trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/create_new_line_layer_definition.aspx
   trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/create_new_point_layer_definition.aspx
   trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/create_new_squarefootage_layer_definition.aspx
   trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/layer_functions.aspx
   trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/task_pane.aspx
Modified:
   trunk/MgDev/Doc/samples/dotnetsamples/common/common.aspx
Log:
Devguide: Implement the modifying_maps_and_layers section of the samples for asp.net

Added: trunk/MgDev/Doc/samples/dotnetsamples/analyzing_features/bufferlayerdefinition.xml
===================================================================
--- trunk/MgDev/Doc/samples/dotnetsamples/analyzing_features/bufferlayerdefinition.xml	                        (rev 0)
+++ trunk/MgDev/Doc/samples/dotnetsamples/analyzing_features/bufferlayerdefinition.xml	2011-11-17 12:00:21 UTC (rev 6232)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+  <LayerDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="LayerDefinition-1.1.0.xsd" version="1.1.0">
+    <VectorLayerDefinition>
+      <ResourceId></ResourceId>
+      <FeatureName>BufferClass</FeatureName>
+      <FeatureNameType>FeatureClass</FeatureNameType>
+      <Geometry>BufferGeometry</Geometry>
+      <VectorScaleRange>
+        <AreaTypeStyle>
+          <AreaRule>
+            <LegendLabel>Buffer</LegendLabel>
+            <AreaSymbolization2D>
+              <Fill>
+                <FillPattern>Solid</FillPattern>
+                <ForegroundColor>22AA00AA</ForegroundColor>
+                <BackgroundColor>FF000000</BackgroundColor>
+              </Fill>
+              <Stroke>
+                <LineStyle>Solid</LineStyle>
+                <Thickness>0</Thickness>
+                <Color>FF666666</Color>
+                <Unit>Inches</Unit>
+                <SizeContext>DeviceUnits</SizeContext>
+              </Stroke>
+            </AreaSymbolization2D>
+          </AreaRule>
+        </AreaTypeStyle>
+      </VectorScaleRange>
+    </VectorLayerDefinition>
+  </LayerDefinition>

Added: trunk/MgDev/Doc/samples/dotnetsamples/analyzing_features/parcelmarker.xml
===================================================================
--- trunk/MgDev/Doc/samples/dotnetsamples/analyzing_features/parcelmarker.xml	                        (rev 0)
+++ trunk/MgDev/Doc/samples/dotnetsamples/analyzing_features/parcelmarker.xml	2011-11-17 12:00:21 UTC (rev 6232)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LayerDefinition version="1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="LayerDefinition-1.1.0.xsd">
+  <VectorLayerDefinition>
+    <ResourceId></ResourceId>
+    <FeatureName>ParcelMarkerClass</FeatureName>
+    <FeatureNameType>FeatureClass</FeatureNameType>
+    <Geometry>ParcelLocation</Geometry>
+    <VectorScaleRange>
+      <MinScale>0</MinScale>
+      <MaxScale>10000</MaxScale>
+      <PointTypeStyle>
+        <DisplayAsText>false</DisplayAsText>
+        <AllowOverpost>false</AllowOverpost>
+        <PointRule>
+          <LegendLabel></LegendLabel>
+          <PointSymbolization2D>
+            <Mark>
+             <Unit>Inches</Unit>
+             <SizeContext>DeviceUnits</SizeContext>
+             <SizeX>.1</SizeX>
+             <SizeY>.1</SizeY>
+             <Rotation>0</Rotation>
+             <Shape>X</Shape>
+             <Fill>
+              <FillPattern>Solid</FillPattern>
+              <ForegroundColor>FFFF0000</ForegroundColor>
+              <BackgroundColor>ff000000</BackgroundColor>
+             </Fill>
+             <Edge>
+              <LineStyle>Solid</LineStyle>
+              <Thickness>0.0</Thickness>
+              <Color>ff000000</Color>
+              <Unit>Centimeters</Unit>
+              <SizeContext>DeviceUnits</SizeContext>
+             </Edge>
+            </Mark>
+          </PointSymbolization2D>
+        </PointRule>
+      </PointTypeStyle>
+    </VectorScaleRange>
+  </VectorLayerDefinition>
+</LayerDefinition>

Modified: trunk/MgDev/Doc/samples/dotnetsamples/common/common.aspx
===================================================================
--- trunk/MgDev/Doc/samples/dotnetsamples/common/common.aspx	2011-11-17 06:31:01 UTC (rev 6231)
+++ trunk/MgDev/Doc/samples/dotnetsamples/common/common.aspx	2011-11-17 12:00:21 UTC (rev 6232)
@@ -32,6 +32,11 @@
         get { return Path.Combine(RootDirectory, "Server"); }
     }
     
+    public static string SchemaDirectory 
+    {
+        get { return Path.Combine(MapGuideServerDirectory, "Schema"); }
+    }
+    
     public static string WebExtensionsDirectory
     {
         get { return Path.Combine(RootDirectory, "Web"); }
@@ -48,4 +53,36 @@
     }
 }
 
+public class TemplateUtil
+{
+    public static String Substitute(String templ, params String[] vals)
+    {
+        StringBuilder res = new StringBuilder();
+        int index = 0, val = 0;
+        bool found;
+        do
+        {
+            found = false;
+            int i = templ.IndexOf('%', index);
+            if(i != -1)
+            {
+                found = true;
+                res.Append(templ.Substring(index, i - index));
+                if(i < templ.Length - 1)
+                {
+                    if(templ[i+1] == '%')
+                        res.Append('%');
+                    else if(templ[i+1] == 's')
+                        res.Append(vals[val ++]);
+                    else
+                        res.Append('@');    //add a character illegal in jscript so we know the template was incorrect
+                    index = i + 2;
+                }
+            }
+        } while(found);
+        res.Append(templ.Substring(index));
+        return res.ToString();
+    }
+}
+
 </script>

Added: trunk/MgDev/Doc/samples/dotnetsamples/common/mapinfo.aspx
===================================================================
--- trunk/MgDev/Doc/samples/dotnetsamples/common/mapinfo.aspx	                        (rev 0)
+++ trunk/MgDev/Doc/samples/dotnetsamples/common/mapinfo.aspx	2011-11-17 12:00:21 UTC (rev 6232)
@@ -0,0 +1,141 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<%--
+  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.Xml" %>
+<%@ Import Namespace="OSGeo.MapGuide" %>
+<!-- #Include File="common.aspx" -->
+<script runat="server">
+String sessionId;
+String mapName;
+</script>
+<html>
+    <head>
+        <title>Map Info</title>
+        <style type="text/css">
+            body, html { margin: 0; padding: 0 }
+            body { font-family: Verdana; font-size: 0.6em; }
+        
+        </style>
+    </head>
+    <body>
+        <%
+        //---------------------------------------------------//
+        // Initialize
+        MapGuideApi.MgInitializeWebTier(Constants.WebConfigPath);
+        sessionId = Request.Params["SESSION"];
+        mapName = Request.Params["MAPNAME"];
+        MgUserInformation userInfo = new MgUserInformation(sessionId);
+        MgSiteConnection siteConnection = new MgSiteConnection();
+        siteConnection.Open(userInfo);
+        
+        MgMap map = new MgMap(siteConnection);
+        map.Open(mapName);
+        %>
+        <p>Map Name: <%= map.GetName() %></p>
+        <p>Object Id: <%= map.GetObjectId() %></p>
+        <p>Map Definition: <%= map.GetMapDefinition().ToString() %></p>
+        <hr />
+        <p>Display DPI: <%= map.GetDisplayDpi() %></p>
+        <p>Display Height: <%= map.GetDisplayHeight() %></p>
+        <p>Display Width: <%= map.GetDisplayWidth() %></p>
+        <hr />
+        <p>View Center: (<%= map.GetViewCenter().GetCoordinate().GetX() %>, <%= map.GetViewCenter().GetCoordinate().GetY() %>)</p>
+        <p>View Scale: <%= map.GetViewScale() %></p>
+        <hr />
+        <%
+        MgEnvelope dataExtents = map.GetDataExtent();
+        MgCoordinate ll = dataExtents.GetLowerLeftCoordinate();
+        MgCoordinate ur = dataExtents.GetUpperRightCoordinate();
+        %>
+        <h3>Data Extents</h3>
+        <p>Lower Left: (<%= ll.GetX() %>, <%= ll.GetY() %>)</p>
+        <p>Upper Left: (<%= ur.GetX() %>, <%= ur.GetY() %>)</p>
+        <hr />
+        <%
+        MgLayerCollection layers = map.GetLayers();
+        %>
+        <h3>Layers (<%= layers.GetCount() %>)</h3>
+        <table border="1">
+            <tr>
+                <th>Name</th>
+                <th>Group</th>
+                <th>Label</th>
+                <th>Legend Visible</th>
+                <th>Potential Visible</th>
+                <th>Actual Visible</th>
+                <th>Expand In Legend</th>
+                <th>Layer Type</th>
+                <th>Layer Definition</th>
+                <th>Feature Source Id</th>
+                <th>Needs Refresh</th>
+            </tr>
+            <% 
+            for (int i = 0; i < layers.GetCount(); i++) { 
+                MgLayerBase layer = layers.GetItem(i);
+                MgLayerGroup group = layer.GetGroup();
+            %>
+            <tr>
+                <td><%= layer.GetName() %></td>
+                <td><%= group == null ? "" : group.Name %></td>
+                <td><%= layer.GetLegendLabel() %></td>
+                <td><%= layer.GetDisplayInLegend() %></td>
+                <td><%= layer.GetVisible() %></td>
+                <td><%= layer.IsVisible() %></td>
+                <td><%= layer.GetExpandInLegend() %></td>
+                <td><%= layer.GetLayerType() %></td>
+                <td><%= layer.GetLayerDefinition().ToString() %></td>
+                <td><%= layer.GetFeatureSourceId() %></td>
+                <td><%= layer.NeedsRefresh() %></td>
+            </tr>
+            <% } %>
+        </table>
+        <hr />
+        <%
+        MgLayerGroupCollection layerGroups = map.GetLayerGroups();
+        %>
+        <h3>Layer Groups (<%= layerGroups.GetCount() %>)</h3>
+        <table border="1">
+            <tr>
+                <th>Name</th>
+                <th>Group</th>
+                <th>Label</th>
+                <th>Legend Visible</th>
+                <th>Potential Visible</th>
+                <th>Actual Visible</th>
+                <th>Expand In Legend</th>
+                <th>Group Type</th>
+            </tr>
+            <% 
+            for (int i = 0; i < layerGroups.GetCount(); i++) { 
+                MgLayerGroup group = layerGroups.GetItem(i);
+                MgLayerGroup parent = group.GetGroup();
+            %>
+            <tr>
+                <td><%= group.GetName() %></td>
+                <td><%= parent == null ? "" : parent.Name %></td>
+                <td><%= group.GetLegendLabel() %></td>
+                <td><%= group.GetDisplayInLegend() %></td>
+                <td><%= group.GetVisible() %></td>
+                <td><%= group.IsVisible() %></td>
+                <td><%= group.GetExpandInLegend() %></td>
+                <td><%= group.GetLayerGroupType() %></td>
+            </tr>
+            <% } %>
+        </table>
+    </body>
+</html>
\ No newline at end of file

Added: trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/RecentlyBuilt.LayerDefinition
===================================================================
--- trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/RecentlyBuilt.LayerDefinition	                        (rev 0)
+++ trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/RecentlyBuilt.LayerDefinition	2011-11-17 12:00:21 UTC (rev 6232)
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LayerDefinition xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="LayerDefinition-1.3.0.xsd">
+	<VectorLayerDefinition>
+		<ResourceId>Library://Samples/Sheboygan/Data/Parcels.FeatureSource</ResourceId>
+		<FeatureName>SHP_Schema:Parcels</FeatureName>
+		<FeatureNameType>FeatureClass</FeatureNameType>
+		<PropertyMapping>
+			<Name>NAME</Name>
+			<Value>NAME</Value>
+		</PropertyMapping>
+		<PropertyMapping>
+			<Name>ID</Name>
+			<Value>ID</Value>
+		</PropertyMapping>
+		<PropertyMapping>
+			<Name>YRBUILT</Name>
+			<Value>YRBUILT</Value>
+		</PropertyMapping>
+		<Geometry>SHPGEOM</Geometry>
+		<VectorScaleRange>
+			<MaxScale>10000</MaxScale>
+			<AreaTypeStyle>
+				<AreaRule>
+					<LegendLabel>Built after 1950</LegendLabel>
+					<Filter>YRBUILT &gt; 1950</Filter>
+					<Label>
+						<Unit>Points</Unit>
+						<SizeContext>DeviceUnits</SizeContext>
+						<SizeX>0.3</SizeX>
+						<SizeY>10</SizeY>
+						<Text>YRBUILT</Text>
+						<FontName>Arial</FontName>
+						<ForegroundColor>FF000000</ForegroundColor>
+						<BackgroundColor>FFFFFFFF</BackgroundColor>
+						<BackgroundStyle>Transparent</BackgroundStyle>
+						<HorizontalAlignment>&apos;Center&apos;</HorizontalAlignment>
+						<VerticalAlignment>&apos;Baseline&apos;</VerticalAlignment>
+					</Label>
+					<AreaSymbolization2D>
+						<Fill>
+							<FillPattern>Solid</FillPattern>
+							<ForegroundColor>FFFFFF00</ForegroundColor>
+							<BackgroundColor>FF000000</BackgroundColor>
+						</Fill>
+						<Stroke>
+							<LineStyle>Solid</LineStyle>
+							<Thickness>0</Thickness>
+							<Color>FF000000</Color>
+							<Unit>Inches</Unit>
+							<SizeContext>DeviceUnits</SizeContext>
+						</Stroke>
+					</AreaSymbolization2D>
+				</AreaRule>
+			</AreaTypeStyle>
+		</VectorScaleRange>
+	</VectorLayerDefinition>
+</LayerDefinition>

Added: trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/change_layers_via_dom.aspx
===================================================================
--- trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/change_layers_via_dom.aspx	                        (rev 0)
+++ trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/change_layers_via_dom.aspx	2011-11-17 12:00:21 UTC (rev 6232)
@@ -0,0 +1,152 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<%--
+  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#" debug="true" %>
+<%@ Import Namespace="System" %>
+<%@ Import Namespace="System.IO" %>
+<%@ Import Namespace="System.Xml" %>
+<%@ Import Namespace="OSGeo.MapGuide" %>
+<script runat="server">
+String sessionId;
+String mapName;
+</script>
+<!-- #Include File="../common/common.aspx" -->
+<!-- #Include File="layer_functions.aspx" -->
+<html>
+
+<head>
+    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+    <meta http-equiv="content-script-type" content="text/javascript">
+    <meta http-equiv="content-style-type" content="text/css">
+    <link href="../styles/globalStyles.css" rel="stylesheet" type="text/css">
+    <link href="../styles/otherStyles.css" rel="stylesheet" type="text/css">
+
+    <script language="javascript" type="text/javascript">
+        function OnPageLoad()
+        {
+            parent.mapFrame.Refresh();
+            parent.mapFrame.ZoomToScale(9999);
+        }
+    </script>
+</head>
+
+<body onLoad="OnPageLoad()">
+
+<%
+try
+{
+    // --------------------------------------------------//
+    // Initialize
+    MapGuideApi.MgInitializeWebTier(Constants.WebConfigPath);
+    sessionId = Request.Params["SESSION"];
+    mapName = Request.Params["MAPNAME"];
+    MgUserInformation userInfo = new MgUserInformation(sessionId);
+    MgSiteConnection siteConnection = new MgSiteConnection();
+    siteConnection.Open(userInfo);
+    
+    MgResourceService resourceService = (MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
+    
+    // --------------------------------------------------//
+    // Open the map
+    MgMap map = new MgMap(siteConnection);
+    map.Open(mapName);
+
+    // ...
+    // --------------------------------------------------//
+    // Load a layer from XML, and use the DOM to change it
+
+    // Load the prototype layer definition into
+    // a PHP DOM object.
+    XmlDocument domDocument = new XmlDocument();
+    String layerDefPath = Server.MapPath("RecentlyBuilt.LayerDefinition");
+    if (!File.Exists(layerDefPath))
+    {
+        Response.Write("The layer definition 'RecentlyBuilt.LayerDefinition' could not be found.<BR>\n");
+        return;
+    }
+    domDocument.Load(layerDefPath);
+
+    // Get a list of all the <AreaRule><Filter> elements in
+    // the XML.
+    XmlNodeList nodes = domDocument.SelectNodes("//AreaRule/Filter");
+    // Find the correct node and change it
+    foreach (XmlNode node in nodes)
+    {
+        if (node.InnerText == "YRBUILT > 1950")
+        {
+            node.InnerText = "YRBUILT > 1980";
+        }
+    }
+
+    // Get a list of all the <LegendLabel> elements in the
+    // XML.
+    nodes = domDocument.SelectNodes("//LegendLabel");
+    // Find the correct node and change it
+    foreach (XmlNode node in nodes)
+    {
+        if (node.InnerText == "Built after 1950")
+        {
+            node.InnerText = "Built after 1980";
+        }
+    }
+
+    // --------------------------------------------------//
+    // ...
+
+    // Add the layer to the map
+    MgLayer newLayer = LayerFunctions.AddLayerDefinitionToMap(domDocument, "RecentlyBuilt", "Built after 1980", sessionId, resourceService, map);
+    LayerFunctions.AddLayerToGroup(newLayer, "Analysis", "Analysis", map);
+
+    // --------------------------------------------------//
+    // Turn off the "Square Footage" themed layer (if it
+    // exists) so it does not hide this layer.
+    MgLayerCollection layerCollection = map.GetLayers();
+    if (layerCollection.Contains("SquareFootage"))
+    {
+        MgLayerBase squareFootageLayer = layerCollection.GetItem("SquareFootage");
+        squareFootageLayer.SetVisible(false);
+    }
+
+    // --------------------------------------------------//
+    // Turn on the visibility of this layer.
+    // (If the layer does not already exist in the map, it will be visible by default when it is added.
+    // But if the user has already run this script, he or she may have set the layer to be invisible.)
+    layerCollection = map.GetLayers();
+    if (layerCollection.Contains("RecentlyBuilt"))
+    {
+        MgLayerBase recentlyBuiltLayer = layerCollection.GetItem("RecentlyBuilt");
+        recentlyBuiltLayer.SetVisible(true);
+    }
+
+    // --------------------------------------------------//
+    //  Save the map back to the session repository
+    map.Save();
+
+    // --------------------------------------------------//
+
+
+}
+catch (MgException e)
+{
+  Response.Write("<script language=\"javascript\" type=\"text/javascript\"> \n");
+  String message = e.GetExceptionMessage().Replace("\n", " ");
+  Response.Write("    alert(\" " + message + " \"); \n");
+  Response.Write("</script> \n");
+}
+%>
+
+</body>
+</html>

Added: trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/create_new_line_layer_definition.aspx
===================================================================
--- trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/create_new_line_layer_definition.aspx	                        (rev 0)
+++ trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/create_new_line_layer_definition.aspx	2011-11-17 12:00:21 UTC (rev 6232)
@@ -0,0 +1,129 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<%--
+  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.Xml" %>
+<%@ Import Namespace="OSGeo.MapGuide" %>
+<script runat="server">
+String sessionId;
+String mapName;
+</script>
+<!-- #Include File="../common/common.aspx" -->
+<!-- #Include File="layer_functions.aspx" -->
+<html>
+
+<head>
+    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+    <meta http-equiv="content-script-type" content="text/javascript">
+    <meta http-equiv="content-style-type" content="text/css">
+    <link href="../styles/globalStyles.css" rel="stylesheet" type="text/css">
+    <link href="../styles/otherStyles.css" rel="stylesheet" type="text/css">
+
+    <script language="javascript" type="text/javascript">
+        function OnPageLoad()
+        {
+            parent.mapFrame.Refresh();
+            parent.mapFrame.ZoomToScale(40000);
+        }
+    </script>
+</head>
+
+<body onLoad="OnPageLoad()">
+
+<%
+try
+{
+    //---------------------------------------------------//
+    // Initialize
+    MapGuideApi.MgInitializeWebTier(Constants.WebConfigPath);
+    sessionId = Request.Params["SESSION"];
+    mapName = Request.Params["MAPNAME"];
+    MgUserInformation userInfo = new MgUserInformation(sessionId);
+    MgSiteConnection siteConnection = new MgSiteConnection();
+    siteConnection.Open(userInfo);
+    MgResourceService resourceService = (MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
+
+    // --------------------------------------------------//
+    // Open the map
+    MgMap map = new MgMap(siteConnection);
+    map.Open(mapName);
+
+	// ...
+    //---------------------------------------------------//
+    // Create a new layer
+
+	LayerDefinitionFactory factory = new LayerDefinitionFactory(this.Server);
+
+    // Create a line rule.
+    String legendLabel = "";
+    String filter = "";
+    String color = "FF0000FF";
+	String lineRule = factory.CreateLineRule(legendLabel, filter, color);
+
+    // Create a line type style.
+    String lineTypeStyle = factory.CreateLineTypeStyle(lineRule);
+
+    // Create a scale range.
+    String minScale = "0";
+    String maxScale = "1000000000000";
+    String lineScaleRange = factory.CreateScaleRange(minScale, maxScale, lineTypeStyle);
+
+    // Create the layer definiton.
+    String featureClass = "Library://Samples/Sheboygan/Data/HydrographicLines.FeatureSource";
+    String featureName = "SHP_Schema:HydrographicLines";
+    String geometry = "SHPGEOM";
+	String layerDefinition = factory.CreateLayerDefinition(featureClass, featureName, geometry, lineScaleRange);
+
+    //---------------------------------------------------//
+    // ...
+
+    XmlDocument doc = new XmlDocument();
+    doc.LoadXml(layerDefinition);
+    // Add the layer to the map
+    MgLayer newLayer = LayerFunctions.AddLayerDefinitionToMap(doc, "Hydro", "Hydro", sessionId, resourceService, map);
+    LayerFunctions.AddLayerToGroup(newLayer, "Analysis", "Analysis", map);
+
+    // --------------------------------------------------//
+    // Turn on the visibility of this layer.
+    // (If the layer does not already exist in the map, it will be visible by default when it is added.
+    // But if the user has already run this script, he or she may have set the layer to be invisible.)
+    MgLayerCollection layerCollection = map.GetLayers();
+    if (layerCollection.Contains("Hydro"))
+    {
+        MgLayerBase squareFootageLayer =layerCollection.GetItem("Hydro");
+        squareFootageLayer.SetVisible(true);
+    }
+
+    //---------------------------------------------------//
+    //  Save the map back to the session repository
+    map.Save();
+
+    //---------------------------------------------------//
+
+}
+catch (MgException e)
+{
+	Response.Write("<script language=\"javascript\" type=\"text/javascript\"> \n");
+	Response.Write("    alert(\" " +e.GetExceptionMessage() + " \"); \n");
+	Response.Write("</script> \n");
+}
+%>
+
+</body>
+</html>
+
+

Added: trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/create_new_point_layer_definition.aspx
===================================================================
--- trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/create_new_point_layer_definition.aspx	                        (rev 0)
+++ trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/create_new_point_layer_definition.aspx	2011-11-17 12:00:21 UTC (rev 6232)
@@ -0,0 +1,229 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<%--
+  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.Xml" %>
+<%@ Import Namespace="OSGeo.MapGuide" %>
+<!-- #Include File="../common/common.aspx" -->
+<!-- #Include File="layer_functions.aspx" -->
+<script runat="server">
+String sessionId;
+String mapName;
+
+///////////////////////////////////////////////////////////////////////////////////
+MgPropertyCollection MakePoint(String name, double x, double y)
+{
+	MgPropertyCollection propertyCollection = new MgPropertyCollection();
+	MgStringProperty nameProperty = new MgStringProperty("NAME", name);
+	propertyCollection.Add(nameProperty);
+
+	MgWktReaderWriter wktReaderWriter = new MgWktReaderWriter();
+	MgAgfReaderWriter agfReaderWriter = new MgAgfReaderWriter();
+
+	MgGeometry geometry = wktReaderWriter.Read("POINT XY (" + x + " " + y + ")");
+	MgByteReader geometryByteReader = agfReaderWriter.Write(geometry);
+	MgGeometryProperty geometryProperty = new MgGeometryProperty("GEOM", geometryByteReader);
+	propertyCollection.Add(geometryProperty);
+
+	return propertyCollection;
+}
+
+</script>
+<html>
+
+<head>
+    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+    <meta http-equiv="content-script-type" content="text/javascript">
+    <meta http-equiv="content-style-type" content="text/css">
+    <link href="../styles/globalStyles.css" rel="stylesheet" type="text/css">
+    <link href="../styles/otherStyles.css" rel="stylesheet"  type="text/css">
+    <script language="javascript" type="text/javascript">
+        function OnPageLoad()
+        {
+            parent.mapFrame.Refresh();
+            parent.mapFrame.ZoomToScale(40000);
+        }
+    </script>
+</head>
+
+<body onLoad="OnPageLoad()">
+
+<%
+try
+{
+    //---------------------------------------------------//
+    // Initialize
+    MapGuideApi.MgInitializeWebTier(Constants.WebConfigPath);
+    sessionId = Request.Params["SESSION"];
+    mapName = Request.Params["MAPNAME"];
+    MgUserInformation userInfo = new MgUserInformation(sessionId);
+    MgSiteConnection siteConnection = new MgSiteConnection();
+    siteConnection.Open(userInfo);
+    MgResourceService resourceService = (MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
+    MgFeatureService featureService = (MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);
+
+    //---------------------------------------------------//
+    // Open the map
+    MgMap map = new MgMap(siteConnection);
+    map.Open(mapName);
+
+    //---------------------------------------------------//
+    // Create a feature source with point data.
+    // (The Sheboygan sample data does not contain such data,
+    // so we"ll create it.)
+
+	// Create a feature class definition for the new feature source
+	MgClassDefinition classDefinition = new MgClassDefinition();
+	classDefinition.SetName("Points");
+	classDefinition.SetDescription("Feature class with point data.");
+	classDefinition.SetDefaultGeometryPropertyName("GEOM");
+
+	// Create an identify property
+	MgDataPropertyDefinition identityProperty = new MgDataPropertyDefinition("KEY");
+	identityProperty.SetDataType(MgPropertyType.Int32);
+	identityProperty.SetAutoGeneration(true);
+	identityProperty.SetReadOnly(true);
+	// Add the identity property to the class definition
+	classDefinition.GetIdentityProperties().Add(identityProperty);
+	classDefinition.GetProperties().Add(identityProperty);
+
+	// Create a name property
+	MgDataPropertyDefinition nameProperty = new MgDataPropertyDefinition("NAME");
+	nameProperty.SetDataType(MgPropertyType.String);
+	// Add the name property to the class definition
+	classDefinition.GetProperties().Add(nameProperty);
+
+	// Create a geometry property
+	MgGeometricPropertyDefinition geometryProperty = new MgGeometricPropertyDefinition("GEOM");
+	geometryProperty.SetGeometryTypes(MgFeatureGeometricType.Point);
+	// Add the geometry property to the class definition
+	classDefinition.GetProperties().Add(geometryProperty);
+
+	// Create a feature schema
+	MgFeatureSchema featureSchema = new MgFeatureSchema("PointSchema", "Point schema");
+	// Add the feature schema to the class definition
+	featureSchema.GetClasses().Add(classDefinition);
+
+	// Create the feature source
+	String featureSourceName = "Library://Samples/DevGuide/Data/points.FeatureSource";
+	MgResourceIdentifier resourceIdentifier = new MgResourceIdentifier(featureSourceName);
+	//wkt = "LOCALCS[\"*XY-MT*\",LOCAL_DATUM[\"*X-Y*\",10000],UNIT[\"Meter\", 1],AXIS[\"X\",EAST],AXIS[\"Y\",NORTH]]";
+    String wkt = map.GetMapSRS();
+	//sdfParams = new MgCreateSdfParams("ArbitraryXY", wkt, featureSchema);
+    MgCreateSdfParams sdfParams = new MgCreateSdfParams("LatLong", wkt, featureSchema);
+    featureService.CreateFeatureSource(resourceIdentifier, sdfParams);
+
+	// We need to add some data to the sdf before using it.  The spatial context
+	// reader must have an extent.
+	MgBatchPropertyCollection batchPropertyCollection = new MgBatchPropertyCollection();
+	MgWktReaderWriter wktReaderWriter = new MgWktReaderWriter();
+	MgAgfReaderWriter agfReaderWriter = new MgAgfReaderWriter();
+	MgGeometryFactory geometryFactory = new MgGeometryFactory();
+
+    // Make four points
+	batchPropertyCollection.Add(MakePoint("Point A", -87.727, 43.748));
+
+	batchPropertyCollection.Add(MakePoint("Point B", -87.728, 43.730));
+
+	batchPropertyCollection.Add(MakePoint("Point C", -87.726, 43.750));
+
+	batchPropertyCollection.Add(MakePoint("Point D", -87.728, 43.750));
+
+	// Add the batch property collection to the feature source
+	MgInsertFeatures cmd = new MgInsertFeatures("Points", batchPropertyCollection);
+	MgFeatureCommandCollection featureCommandCollection = new MgFeatureCommandCollection();
+	featureCommandCollection.Add(cmd);
+
+	// Execute the "add" commands
+	featureService.UpdateFeatures(resourceIdentifier, featureCommandCollection, false);
+
+    // ...
+    //---------------------------------------------------//
+    // Create a new layer
+
+    LayerDefinitionFactory factory = new LayerDefinitionFactory(this.Server);
+
+    // Create a mark symbol
+    String resourceId = "Library://Samples/Sheboygan/Symbols/BasicSymbols.SymbolLibrary";
+    String symbolName = "PushPin";
+    String width = "24";  // unit = points
+    String height = "24"; // unit = points
+    String color = "FFFF0000";
+    String markSymbol = factory.CreateMarkSymbol(resourceId, symbolName, width, height, color);
+
+    // Create a text symbol
+    String text = "ID";
+    String fontHeight="12";
+    String foregroundColor = "FF000000";
+    String textSymbol = factory.CreateTextSymbol(text, fontHeight, foregroundColor);
+
+    // Create a point rule.
+    String legendLabel = "trees";
+    String filter = "";
+    String pointRule = factory.CreatePointRule(legendLabel, filter, textSymbol, markSymbol);
+
+    // Create a point type style.
+    String pointTypeStyle = factory.CreatePointTypeStyle(pointRule);
+
+    // Create a scale range.
+    String minScale = "0";
+    String maxScale = "1000000000000";
+    String pointScaleRange = factory.CreateScaleRange(minScale, maxScale, pointTypeStyle);
+
+    // Create the layer definiton.
+    String featureName = "PointSchema:Points";
+    String geometry = "GEOM";
+    String layerDefinition = factory.CreateLayerDefinition(featureSourceName, featureName, geometry, pointScaleRange);
+    //---------------------------------------------------//
+    // ...
+
+    XmlDocument doc = new XmlDocument();
+    doc.LoadXml(layerDefinition);
+    // Add the layer to the map
+    MgLayer newLayer = LayerFunctions.AddLayerDefinitionToMap(doc, "Points", "Points of Interest", sessionId, resourceService, map);
+    LayerFunctions.AddLayerToGroup(newLayer, "Analysis", "Analysis", map);
+
+    // --------------------------------------------------//
+    // Turn on the visibility of this layer.
+    // (If the layer does not already exist in the map, it will be visible by default when it is added.
+    // But if the user has already run this script, he or she may have set the layer to be invisible.)
+    MgLayerCollection layerCollection = map.GetLayers();
+    if (layerCollection.Contains("Points"))
+    {
+        MgLayerBase pointsLayer =layerCollection.GetItem("Points");
+        pointsLayer.SetVisible(true);
+    }
+
+    //---------------------------------------------------//
+    //  Save the map back to the session repository
+    map.Save();
+
+    //---------------------------------------------------//
+}
+catch (MgException e)
+{
+	Response.Write("<script language=\"javascript\" type=\"text/javascript\"> \n");
+	Response.Write("    alert(\" " + e.GetExceptionMessage() + " \"); \n");
+	Response.Write("</script> \n");
+}
+
+%>
+
+</body>
+</html>
+
+

Added: trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/create_new_squarefootage_layer_definition.aspx
===================================================================
--- trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/create_new_squarefootage_layer_definition.aspx	                        (rev 0)
+++ trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/create_new_squarefootage_layer_definition.aspx	2011-11-17 12:00:21 UTC (rev 6232)
@@ -0,0 +1,141 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<%--
+  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.Xml" %>
+<%@ Import Namespace="OSGeo.MapGuide" %>
+<!-- #Include File="../common/common.aspx" -->
+<!-- #Include File="layer_functions.aspx" -->
+<script runat="server">
+String sessionId;
+String mapName;
+</script>
+<html>
+
+<head>
+    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+    <meta http-equiv="content-script-type" content="text/javascript">
+    <meta http-equiv="content-style-type" content="text/css">
+    <link href="../styles/globalStyles.css" rel="stylesheet" type="text/css">
+    <link href="../styles/otherStyles.css" rel="stylesheet" type="text/css">
+
+    <script language="javascript" type="text/javascript">
+        function OnPageLoad()
+        {
+            parent.mapFrame.Refresh();
+            parent.mapFrame.ZoomToScale(9999);
+        }
+    </script>
+</head>
+
+<body onLoad="OnPageLoad()">
+
+<%
+try
+{
+    //---------------------------------------------------//
+    // Initialize
+    MapGuideApi.MgInitializeWebTier(Constants.WebConfigPath);
+    sessionId = Request.Params["SESSION"];
+    mapName = Request.Params["MAPNAME"];
+
+    MgUserInformation userInfo = new MgUserInformation(sessionId);
+    MgSiteConnection siteConnection = new MgSiteConnection();
+    siteConnection.Open(userInfo);
+    MgResourceService resourceService = (MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
+
+    // --------------------------------------------------//
+    // Open the map
+    MgMap map = new MgMap(siteConnection);
+    map.Open(mapName);
+
+
+	// ...
+    //---------------------------------------------------//
+    // Create a new layer
+    LayerDefinitionFactory factory = new LayerDefinitionFactory(this.Server);
+
+    /// Create three area rules for three different
+    // scale ranges.
+    String areaRule1 = factory.CreateAreaRule(    "1 to 800",
+      "SQFT &gt;= 1 AND SQFT &lt; 800",     "FFFFFF00");
+    String areaRule2 = factory.CreateAreaRule( "800 to 1600",
+      "SQFT &gt;= 800 AND SQFT &lt; 1600",  "FFFFBF20");
+    String areaRule3 = factory.CreateAreaRule("1600 to 2400",
+      "SQFT &gt;= 1600 AND SQFT &lt; 2400", "FFFF8040");
+
+    // Create an area type style.
+    String areaTypeStyle = factory.CreateAreaTypeStyle(areaRule1 + areaRule2 + areaRule3);
+
+    // Create a scale range.
+    String minScale = "0";
+    String maxScale = "10000";
+    String areaScaleRange = factory.CreateScaleRange(minScale, maxScale, areaTypeStyle);
+
+    // Create the layer definiton.
+    String featureClass = "Library://Samples/Sheboygan/Data/Parcels.FeatureSource";
+    String featureName = "SHP_Schema:Parcels";
+    String geometry = "SHPGEOM";
+    String layerDefinition = factory.CreateLayerDefinition(featureClass, featureName, geometry, areaScaleRange);
+
+    XmlDocument doc = new XmlDocument();
+    doc.LoadXml(layerDefinition);
+
+    //---------------------------------------------------//
+    // ...
+
+    // Add the layer to the map
+    MgLayer newLayer = LayerFunctions.AddLayerDefinitionToMap(doc, "SquareFootage", "Square Footage", sessionId, resourceService, map);
+    LayerFunctions.AddLayerToGroup(newLayer, "Analysis", "Analysis", map);
+    
+    //---------------------------------------------------//
+    // Turn off the "Recently Built" themed layer (if it exists) so it does not hide this layer.
+    MgLayerCollection layerCollection = map.GetLayers();
+    if (layerCollection.Contains("RecentlyBuilt"))
+    {
+        MgLayerBase recentlyBuiltLayer =layerCollection.GetItem("RecentlyBuilt");
+        recentlyBuiltLayer.SetVisible(false);
+    }
+
+    // --------------------------------------------------//
+    // Turn on the visibility of this layer.
+    // (If the layer does not already exist in the map, it will be visible by default when it is added.
+    // But if the user has already run this script, he or she may have set the layer to be invisible.)
+    layerCollection = map.GetLayers();
+    if (layerCollection.Contains("SquareFootage"))
+    {
+        MgLayerBase squareFootageLayer =layerCollection.GetItem("SquareFootage");
+        squareFootageLayer.SetVisible(true);
+    }
+
+    //---------------------------------------------------//
+    //  Save the map back to the session repository
+    map.Save();
+
+    //---------------------------------------------------//
+}
+catch (MgException e)
+{
+	Response.Write( "<script language=\"javascript\" type=\"text/javascript\"> \n");
+	Response.Write( "    alert(\" " + e.GetExceptionMessage() + " \"); \n");
+	Response.Write( "</script> \n");
+}
+%>
+
+</body>
+</html>
+

Added: trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/layer_functions.aspx
===================================================================
--- trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/layer_functions.aspx	                        (rev 0)
+++ trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/layer_functions.aspx	2011-11-17 12:00:21 UTC (rev 6232)
@@ -0,0 +1,225 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<%--
+  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
+--%>
+<%@ Import Namespace="System" %>
+<%@ Import Namespace="OSGeo.MapGuide" %>
+<!-- #Include File="../common/common.aspx" -->
+<script language="C#" runat="server">
+public class LayerFunctions
+{
+    // Adds the layer definition (XML) to the map.
+    // Returns the layer.
+    public static MgLayer AddLayerDefinitionToMap(XmlDocument domDocument, String layerName, String layerLegendLabel, String sessionId, MgResourceService resourceService, MgMap map)
+    {
+        // TODO: Should probably validate this XML content
+
+        using (MemoryStream ms = new MemoryStream())
+        {
+            domDocument.Save(ms);
+            ms.Position = 0L;
+            // Save the new layer definition to the session repository  
+            MgByteSource byteSource = new MgByteSource(ms.GetBuffer(), (int)ms.Length);
+            byteSource.SetMimeType(MgMimeType.Xml);
+            MgResourceIdentifier resourceID = new MgResourceIdentifier("Session:" + sessionId + "//" + layerName + ".LayerDefinition");
+            resourceService.SetResource(resourceID, byteSource.GetReader(), null);
+            
+            MgLayer newLayer = AddLayerResourceToMap(resourceID, resourceService, layerName, layerLegendLabel, map);
+
+            return newLayer;
+        }
+    }
+
+    //////////////////////////////////////////////////////////////
+    // Adds a layer to a layer group. If necessary, it creates the layer group.
+    public static void AddLayerToGroup(MgLayer layer, String layerGroupName, String layerGroupLegendLabel, MgMap map)
+    {
+        // Get the layer group
+        MgLayerGroupCollection layerGroupCollection = map.GetLayerGroups();
+        MgLayerGroup layerGroup = null;
+        if (layerGroupCollection.Contains(layerGroupName))
+        {
+            layerGroup = layerGroupCollection.GetItem(layerGroupName);
+        }
+        else
+        {
+            // It does not exist, so create it
+            layerGroup = new MgLayerGroup(layerGroupName); 
+            layerGroup.SetVisible(true);
+            layerGroup.SetDisplayInLegend(true);
+            layerGroup.SetLegendLabel(layerGroupLegendLabel);
+            layerGroupCollection.Add(layerGroup); 
+        }
+
+        // Add the layer to the group
+        layer.SetGroup(layerGroup);  
+    }
+
+    //////////////////////////////////////////////////////////////
+    // Adds a layer defition (which can be stored either in the Library or a session
+    // repository) to the map.
+    // Returns the layer.
+    public static MgLayer AddLayerResourceToMap(MgResourceIdentifier layerResourceID, MgResourceService resourceService, String layerName, String layerLegendLabel, MgMap map)
+    {
+        MgLayer newLayer = new MgLayer(layerResourceID, resourceService);  
+
+        // Add the new layer to the map's layer collection
+        newLayer.SetName(layerName);
+        newLayer.SetVisible(true);
+        newLayer.SetLegendLabel(layerLegendLabel);
+        newLayer.SetDisplayInLegend(true);
+        MgLayerCollection layerCollection = map.GetLayers(); 
+        if (!layerCollection.Contains(layerName) )
+        {
+            // Insert the new layer at position 0 so it is at the top
+            // of the drawing order
+            layerCollection.Insert(0, newLayer); 
+        }
+
+        return newLayer;
+    }
+}
+
+public class LayerDefinitionFactory
+{
+    private HttpServerUtility _server;
+
+    public LayerDefinitionFactory(HttpServerUtility server) 
+    { 
+        _server = server;
+    }
+    
+    HttpServerUtility Server { get { return _server; } }
+    
+    //Creates Area Rule
+    //Parameters:
+    //foreGroundColor - color code for the foreground color
+    //legendLabel - string for the legend label
+    //filterText - filter string
+    //textSymbol - use textsymbol.templ to create it
+    public String CreateAreaRule(String legendLabel, String filterText, String foreGroundColor)
+    {
+        String areaRule = File.ReadAllText(Server.MapPath("../../viewerfiles/arearule.templ"));
+        areaRule = TemplateUtil.Substitute(areaRule, legendLabel, filterText, foreGroundColor);
+        return areaRule;
+    }
+
+    //Creates AreaTypeStyle.
+    //Parameters:
+    //areaRules - call CreateAreaRule to create area rules
+    public String CreateAreaTypeStyle(String areaRules)
+    {
+        String style = File.ReadAllText(Server.MapPath("../../viewerfiles/areatypestyle.templ"));
+        style = TemplateUtil.Substitute(style, areaRules);
+        return style;
+    }
+
+    //Creates line rule
+    //Parameters:
+    //color - color code for the line
+    //legendLabel - string for the legend label
+    //filter - filter string
+    public String CreateLineRule(String legendLabel, String filter, String color)
+    {
+        String lineRule = File.ReadAllText(Server.MapPath("../../viewerfiles/linerule.templ"));
+        lineRule = TemplateUtil.Substitute(lineRule, legendLabel, filter, color);
+        return lineRule;
+    }
+
+    //Creates LineTypeStyle
+    //Parameters:
+    //lineRules - call CreateLineRule to create line rules
+    public String CreateLineTypeStyle(String lineRules)
+    {
+        String lineStyle = File.ReadAllText(Server.MapPath("../../viewerfiles/linetypestyle.templ"));
+        lineStyle = TemplateUtil.Substitute(lineStyle, lineRules);
+        return lineStyle;
+    }
+
+    //Creates mark symbol
+    //Parameters:
+    //resourceId - resource identifier for the resource to be used
+    //symbolName - the name of the symbol
+    //width - the width of the symbol
+    //height - the height of the symbol
+    //color - color code for the symbol color
+    public String CreateMarkSymbol(String resourceId, String symbolName, String width, String height, String color)
+    {
+        String markSymbol = File.ReadAllText(Server.MapPath("../../viewerfiles/marksymbol.templ"));
+        markSymbol = TemplateUtil.Substitute(markSymbol, width, height, resourceId, symbolName, color);
+        return markSymbol;
+    }
+
+    //Creates text symbol
+    //Parameters:
+    //text - string for the text
+    //fontHeight - the height for the font
+    //TODO:Can we pass it as a integer (ex. 10) or string (ex"10")
+    //foregroundColor - color code for the foreground color
+    public String CreateTextSymbol(String text, String fontHeight, String foregroundColor)
+    {
+        String textSymbol = File.ReadAllText(Server.MapPath("../../viewerfiles/textsymbol.templ"));
+        textSymbol = TemplateUtil.Substitute(textSymbol, fontHeight, fontHeight, text, foregroundColor);
+        return textSymbol;
+    }
+
+    //Creates a point rule
+    //Parameters:
+    //pointSym - point symbolization. Use CreateMarkSymbol to create it
+    //legendlabel - string for the legend label
+    //filter - string for the filter
+    //label - use CreateTextSymbol to create it
+    public String CreatePointRule(String legendLabel, String filter, String label, String pointSym)
+    {
+        String pointRule = File.ReadAllText(Server.MapPath("../../viewerfiles/pointrule.templ"));
+        pointRule = TemplateUtil.Substitute(pointRule, legendLabel, filter, label, pointSym);
+        return pointRule;
+    }
+
+    //Creates PointTypeStyle
+    //Parameters:
+    //pointRule - use CreatePointRule to define rules
+    public String CreatePointTypeStyle(String pointRule)
+    {
+        String pointTypeStyle = File.ReadAllText(Server.MapPath("../../viewerfiles/pointtypestyle.templ"));
+        pointTypeStyle = TemplateUtil.Substitute(pointTypeStyle, pointRule);
+        return pointTypeStyle;
+    }
+
+    //Creates ScaleRange
+    //Parameterss
+    //minScale - minimum scale
+    //maxScale - maximum scale
+    //typeStyle - use one CreateAreaTypeStyle, CreateLineTypeStyle, or CreatePointTypeStyle
+    public String CreateScaleRange(String minScale, String maxScale, String typeStyle)
+    {
+        String scaleRange = File.ReadAllText(Server.MapPath("../../viewerfiles/scalerange.templ"));
+        scaleRange = TemplateUtil.Substitute(scaleRange, minScale, maxScale, typeStyle);
+        return scaleRange;
+    }
+
+    //Creates a layer definition
+    //resourceId - resource identifier for the new layer
+    //featureClass - the name of the feature class
+    //geometry - the name of the geometry
+    //featureClassRange - use CreateScaleRange to define it.
+    public String CreateLayerDefinition(String resourceId, String featureClass, String geometry, String featureClassRange)
+    {
+        String layerDef = File.ReadAllText(Server.MapPath("../../viewerfiles/layerdefinition.templ"));
+        layerDef = TemplateUtil.Substitute(layerDef, resourceId, featureClass, geometry, featureClassRange);
+        return layerDef;
+    }
+}
+</script>

Added: trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/task_pane.aspx
===================================================================
--- trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/task_pane.aspx	                        (rev 0)
+++ trunk/MgDev/Doc/samples/dotnetsamples/modifying_maps_and_layers/task_pane.aspx	2011-11-17 12:00:21 UTC (rev 6232)
@@ -0,0 +1,90 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<%--
+  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" %>
+<script runat="server">
+String sessionId;
+String mapName;
+String fullPath;
+</script>
+<html>
+  <head>
+    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+    <meta http-equiv="content-script-type" content="text/javascript">
+    <meta http-equiv="content-style-type" content="text/css">
+    <link href="../styles/globalStyles.css" rel="stylesheet" type="text/css">
+    <link href="../styles/otherStyles.css" rel="stylesheet" type="text/css">
+  </head>
+  <body class="AppFrame">
+    <h1 class="AppHeading">Modifying Maps &amp; Layers</h1>
+      <p>The following links all load in the hidden script frame, leaving this task pane visible.</p>
+      <%
+        sessionId = Request.Params["SESSION"];
+        mapName = Request.Params["MAPNAME"];
+      %>
+      <ul>
+        <li><a href="change_layers_via_dom.aspx?SESSION=<%= sessionId %>&MAPNAME=<%= mapName %>" target="scriptFrame">
+          Change Layers via DOM</a>         
+          <br>Show buildings built after 1980.
+          <br>
+          <% 
+            fullPath = Server.MapPath("change_layers_via_dom.aspx");
+          %>
+            <a target="_blank" href="../common/viewsource.aspx?FILENAME=<%= fullPath %>" >View source</a>
+        </li>
+        
+        <li><a href="create_new_squarefootage_layer_definition.aspx?SESSION=<%= sessionId %>&MAPNAME=<%= mapName %>" target="scriptFrame">
+          Create Square Footage Layer</a>
+          <br>Show a map themed by areas.
+          <br>
+          <% 
+            fullPath = Server.MapPath("create_new_squarefootage_layer_definition.aspx");
+          %>
+            <a target="_blank" href="../common/viewsource.aspx?FILENAME=<%= fullPath %>" >View source</a>     
+        </li>
+        
+        <li><a href="create_new_line_layer_definition.aspx?SESSION=<%= sessionId %>&MAPNAME=<%= mapName %>" target="scriptFrame">
+          Create Hydro Line Layer</a>
+          <br>Show a map themed by lines.
+          <br>
+          <% 
+            fullPath = Server.MapPath("create_new_line_layer_definition.aspx");
+          %>
+            <a target="_blank" href="../common/viewsource.aspx?FILENAME=<%= fullPath %>" >View source</a>   
+        </li>
+        
+        <li><a href="create_new_point_layer_definition.aspx?SESSION=<%= sessionId %>&MAPNAME=<%= mapName %>" target="scriptFrame">
+          Create Points of Interest Layer</a>
+          <br>Show a map themed by points.
+          <br>
+          <% 
+            fullPath = Server.MapPath("create_new_point_layer_definition.aspx");
+            String fullPath2 = Server.MapPath("RecentlyBuilt.LayerDefinition");
+            String fullPath3 = Server.MapPath("layer_functions.aspx");
+          %>
+            <a target="_blank" href="../common/viewsource.aspx?FILENAME=<%= fullPath %>" >View source</a>         
+        </li> 
+      </ul>     
+    <p>View source for support files:</p>
+    <ul>
+      <li><a target="_blank" href="../common/viewsource.aspx?FILENAME=<%= fullPath2 %>">RecentlyBuilt.LayerDefinition</a></li>
+      <li><a target="_blank" href="../common/viewsource.aspx?FILENAME=<%= fullPath3 %>">layer_functions.aspx</a></li>
+    </ul>
+    <p>Map Debugging:</p>
+    <a target="_blank" href="../common/mapinfo.aspx?SESSION=<%= sessionId %>&MAPNAME=<%= mapName %>">Map Information</a>
+  </body>
+</html>



More information about the mapguide-commits mailing list