protected void Page_Load(object sender, EventArgs e) { string agent = ConfigurationManager.AppSettings["MapAgentUrl"]; IServerConnection conn = ConnectionProviderRegistry.CreateConnection( "Maestro.Http", "Url", agent, "SessionId", Request.Params["SESSION"]); IMappingService mpSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping); string rtMapId = "Session:" + conn.SessionID + "//" + Request.Params["MAPNAME"] + ".Map"; RuntimeMap rtMap = mpSvc.OpenMap(rtMapId); RuntimeMapGroup group = rtMap.Groups[Request.Params["GROUPNAME"]]; if (group != null) { group.Visible = !group.Visible; rtMap.Save(); //Always save changes after modifying Page.ClientScript.RegisterStartupScript( this.GetType(), "load", "<script type=\"text/javascript\"> window.onload = function() { parent.parent.Refresh(); } </script>"); lblMessage.Text = "Group (" + group.Name + ") visible: " + group.Visible; } else { lblMessage.Text = "Group (" + group.Name + ") not found!"; } }
private bool HasVisibleParent(RuntimeMapGroup grp) { if (string.IsNullOrEmpty(grp.Group)) { return(true); } var current = _map.Groups[grp.Group]; if (current != null) { return(current.Visible); } return(true); }
private TreeNode CreateGroupNode(RuntimeMapGroup group) { var node = new TreeNode(group.LegendLabel); node.Tag = new GroupDecorator(group); node.ImageIndex = node.SelectedImageIndex = group.Visible ? IDX_GROUP : IDX_GROUP_HIDDEN; foreach (var grp in _rtMap.GetGroupsOfGroup(group.Name)) { node.Nodes.Add(CreateGroupNode(grp)); } foreach (var layer in _rtMap.GetLayersOfGroup(group.Name)) { node.Nodes.Add(CreateLayerNode(layer)); } return(node); }
internal bool GetVisibilityFlag(RuntimeMapGroup group) => this.ShowAllLayersAndGroups;
protected void Page_Load(object sender, EventArgs e) { string agent = ConfigurationManager.AppSettings["MapAgentUrl"]; IServerConnection conn = ConnectionProviderRegistry.CreateConnection( "Maestro.Http", "Url", agent, "SessionId", Request.Params["SESSION"]); IMappingService mpSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping); string rtMapId = "Session:" + conn.SessionID + "//" + Request.Params["MAPNAME"] + ".Map"; RuntimeMap rtMap = mpSvc.OpenMap(rtMapId); RuntimeMapLayer tracks = rtMap.Layers["Tracks"]; if (tracks != null) { lblMessage.Text = "Tracks layer already added"; } else { string groupName = "Transportation"; RuntimeMapGroup group = rtMap.Groups[groupName]; if (group == null) { group = mpSvc.CreateMapGroup(rtMap, groupName); rtMap.Groups.Add(group); } //For some reason, the Sheboygan sample data does not have a Rail //Layer Definition, so what better time to show how to create a //layer dynamically :) //Our Feature Source string fsId = "Library://Samples/Sheboygan/Data/Rail.FeatureSource"; //The place we'll store the layer definition string layerId = "Session:" + conn.SessionID + "//Rail.LayerDefinition"; CreateTracksLayer(conn, fsId, layerId); ILayerDefinition layerDef = (ILayerDefinition)conn.ResourceService.GetResource(layerId); RuntimeMapLayer layer = mpSvc.CreateMapLayer(rtMap, layerDef); layer.Group = groupName; layer.Name = "Tracks"; layer.LegendLabel = "Tracks"; layer.ShowInLegend = true; layer.ExpandInLegend = true; layer.Selectable = true; layer.Visible = true; //Set it to be drawn above districts. //In terms of draw order, it goes [0...n] -> [TopMost ... Bottom] //So for a layer to be drawn above something else, its draw order must be //less than that particular layer. int index = rtMap.Layers.IndexOf("Districts"); rtMap.Layers.Insert(index, layer); rtMap.Save(); Page.ClientScript.RegisterStartupScript( this.GetType(), "load", "<script type=\"text/javascript\"> window.onload = function() { parent.parent.Refresh(); } </script>"); lblMessage.Text = "Tracks layer added again"; } rtMap = mpSvc.OpenMap(rtMapId); DumpMap(rtMap); }
public GroupDecorator(RuntimeMapGroup group) { _group = group; }
internal GroupNodeMetadata(RuntimeMapGroup group) { base.IsGroup = true; this.Group = group; this.Checkable = true; }
protected void Page_Load(object sender, EventArgs e) { string agent = ConfigurationManager.AppSettings["MapAgentUrl"]; IServerConnection conn = ConnectionProviderRegistry.CreateConnection( "Maestro.Http", "Url", agent, "SessionId", Request.Params["SESSION"]); IMappingService mpSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping); string rtMapId = "Session:" + conn.SessionID + "//" + Request.Params["MAPNAME"] + ".Map"; RuntimeMap rtMap = mpSvc.OpenMap(rtMapId); RuntimeMapLayer parcels = rtMap.Layers["Parcels"]; if (parcels != null) { rtMap.Layers.Remove(parcels); rtMap.Save(); Page.ClientScript.RegisterStartupScript( this.GetType(), "load", "<script type=\"text/javascript\"> window.onload = function() { parent.parent.Refresh(); } </script>"); lblMessage.Text = "Parcels layer removed"; } else { string groupName = "Municipal"; RuntimeMapGroup group = rtMap.Groups[groupName]; if (group == null) { group = mpSvc.CreateMapGroup(rtMap, groupName); rtMap.Groups.Add(group); throw new Exception("Layer group not found"); } ILayerDefinition layerDef = (ILayerDefinition)conn.ResourceService.GetResource("Library://Samples/Sheboygan/Layers/Parcels.LayerDefinition"); RuntimeMapLayer layer = mpSvc.CreateMapLayer(rtMap, layerDef); layer.Group = group.Name; layer.LegendLabel = "Parcels"; layer.ShowInLegend = true; layer.ExpandInLegend = true; layer.Selectable = true; layer.Visible = true; //Set it to be drawn above islands. //In terms of draw order, it goes [0...n] -> [TopMost ... Bottom] //So for a layer to be drawn above something else, its draw order must be //less than that particular layer. int index = rtMap.Layers.IndexOf("Islands"); rtMap.Layers.Insert(index, layer); rtMap.Save(); Page.ClientScript.RegisterStartupScript( this.GetType(), "load", "<script type=\"text/javascript\"> window.onload = function() { parent.parent.Refresh(); } </script>"); lblMessage.Text = "Parcels layer added again"; } rtMap = mpSvc.OpenMap(rtMapId); DumpMap(rtMap); }