private void drawOrderCtrl_LayerDeleted(object sender, RuntimeMapLayer layer) { if (layer == propGrid.SelectedObject) { propGrid.SelectedObject = null; } }
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 layer = rtMap.Layers[Request.Params["LAYERNAME"]]; if (layer != null) { layer.Visible = !layer.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 = "Layer (" + layer.Name + ") visible: " + layer.Visible; } else { lblMessage.Text = "Layer (" + layer.Name + ") not found!"; } }
private TreeNode CreateLayerNode(RuntimeMapLayer layer) { var node = new TreeNode((layer.LegendLabel != String.Empty) ? layer.LegendLabel : String.Format("[{0}]", layer.Name)); node.Tag = new LayerDecorator(layer); node.ImageIndex = node.SelectedImageIndex = layer.Visible ? IDX_LAYER : IDX_LAYER_HIDDEN; return(node); }
protected void btnDescribe_Click(object sender, EventArgs e) { string agent = ConfigurationManager.AppSettings["MapAgentUrl"]; MAPNAME.Value = Request.Params["MAPNAME"]; SESSION.Value = Request.Params["SESSION"]; IServerConnection conn = ConnectionProviderRegistry.CreateConnection( "Maestro.Http", "Url", agent, "SessionId", SESSION.Value); IMappingService mpSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping); string rtMapId = "Session:" + conn.SessionID + "//" + MAPNAME.Value + ".Map"; RuntimeMap rtMap = mpSvc.OpenMap(rtMapId); //Get the selected layer RuntimeMapLayer rtLayer = rtMap.Layers.GetByObjectId(ddlLayers.SelectedValue); //Get the class definition ClassDefinition clsDef = conn.FeatureService.GetClassDefinition(rtLayer.FeatureSourceID, rtLayer.QualifiedClassName); StringBuilder sb = new StringBuilder(); sb.Append("<h3>Layer Properties</h3><hr/>"); sb.Append("<p>Name: " + rtLayer.Name + "</p>"); sb.Append("<p>Legend Label: " + rtLayer.LegendLabel + "</p>"); sb.Append("<p>Display Level: " + rtLayer.DisplayOrder + "</p>"); sb.Append("<p>Expand In Legend: " + rtLayer.ExpandInLegend + "</p>"); sb.Append("<p>Show In Legend: " + rtLayer.ShowInLegend + "</p>"); sb.Append("<p>Visible: " + rtLayer.Visible + "</p>"); sb.Append("<p>Layer Definition: " + rtLayer.LayerDefinitionID + "</p>"); sb.Append("<p>Has Tooltips: " + rtLayer.HasTooltips + "</p>"); sb.Append("<p>Filter: " + rtLayer.Filter + "</p>"); sb.Append("<h3>Class Definition</h3><hr/>"); sb.Append("<p>Schema: " + clsDef.QualifiedName.Split(':')[0] + "</p>"); sb.Append("<p>Class Name: " + clsDef.Name + "</p>"); sb.Append("<strong>Properties (* indicates identity):</strong>"); sb.Append("<ul>"); for (int i = 0; i < clsDef.Properties.Count; i++) { PropertyDefinition prop = clsDef.Properties[i]; bool isIdentity = false; if (prop.Type == PropertyDefinitionType.Data) { isIdentity = clsDef.IdentityProperties.Contains((DataPropertyDefinition)prop); } string name = (isIdentity ? "* " + prop.Name : prop.Name); sb.AppendFormat("<li><p>Name: {0}</p><p>Type: {1}</p></li>", name, prop.Type.ToString()); } sb.Append("</ul>"); classDef.InnerHtml = sb.ToString(); }
private void OnLayerSelected(RuntimeMapLayer layer) { var h = this.LayerSelected; if (h != null) { h(this, layer); } }
protected void btnSelect_Click(object sender, EventArgs e) { string agent = ConfigurationManager.AppSettings["MapAgentUrl"]; MAPNAME.Value = Request.Params["MAPNAME"]; SESSION.Value = Request.Params["SESSION"]; IServerConnection conn = ConnectionProviderRegistry.CreateConnection( "Maestro.Http", "Url", agent, "SessionId", SESSION.Value); IMappingService mpSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping); string rtMapId = "Session:" + conn.SessionID + "//" + MAPNAME.Value + ".Map"; RuntimeMap rtMap = mpSvc.OpenMap(rtMapId); //Get the selected layer RuntimeMapLayer rtLayer = rtMap.Layers.GetByObjectId(ddlLayers.SelectedValue); //Query using the user filter IFeatureReader reader = conn.FeatureService.QueryFeatureSource( rtLayer.FeatureSourceID, rtLayer.QualifiedClassName, txtFilter.Text); //Get the selection set MapSelection sel = new MapSelection(rtMap); MapSelection.LayerSelection layerSel = null; if (!sel.Contains(rtLayer)) { sel.Add(rtLayer); } layerSel = sel[rtLayer]; //Clear any existing selections layerSel.Clear(); //Populate selection set with query result int added = layerSel.AddFeatures(reader, -1); //Generate selection string string selXml = sel.ToXml(); //Generate a client-side set selection and execute a "Zoom to Selection" afterwards Page.ClientScript.RegisterStartupScript( this.GetType(), "load", "<script type=\"text/javascript\"> window.onload = function() { parent.parent.GetMapFrame().SetSelectionXML('" + selXml + "'); parent.parent.ExecuteMapAction(10); } </script>"); lblMessage.Text = added + " features in " + rtLayer.Name + " selected"; }
private void OnMapLayerAdded(object sender, RuntimeMapLayer layer) { if (_bComputeLayerCsAndExtentOnFirstLayerAdded && _mapEditor.Map.Layers.Count == 1) { Debug.WriteLine("Computing map extents and CS based on first layer added"); try { ILayerDefinition layerDef = (ILayerDefinition)_conn.ResourceService.GetResource(layer.LayerDefinitionID); string wkt; IEnvelope env = layerDef.GetSpatialExtent(_conn, true, out wkt); if (SupportsMutableMapProperties(_mapEditor.Map)) { _mapEditor.Map.MapExtent = env; _mapEditor.Map.CoordinateSystem = wkt; if (CsHelper.DefaultCalculator != null) { _mapEditor.Map.MetersPerUnit = CsHelper.DefaultCalculator.Calculate(wkt, 1.0); } else { var calc = _mapEditor.Map.CurrentConnection.GetCalculator(); _mapEditor.Map.MetersPerUnit = calc.Calculate(wkt, 1.0); } _mapEditor.ReloadViewer(); } else { //We have to tear down the current runtime map, update the shadow copy //map definition and then rebuild a new runtime map _mapEditor.SyncMap(); IMapDefinition mdf = _mapEditor.GetMapDefinition(); mdf.Extents = env; mdf.CoordinateSystem = wkt; CleanupExistingMap(); //If local, we'd be rebuilding off of the resource ID and not its in-memory //object representation so flush _mapEditor.EditorService.SyncSessionCopy(); _mapEditor.RebuildRuntimeMap(); _mapEditor.ReloadViewer(); } Debug.WriteLine("Computed map extents and CS"); } catch (Exception ex) { Debug.WriteLine("Uh-Oh: " + ex.ToString()); } } }
private bool HasVisibleParent(RuntimeMapLayer layer) { if (string.IsNullOrEmpty(layer.Group)) { return(true); } var current = _map.Groups[layer.Group]; if (current != null) { return(current.Visible); } return(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 tracks = rtMap.Layers["ThemedDistricts"]; if (tracks != null) { lblMessage.Text = "Themed districts layer already added"; } else { //Add our themed districts layer //Our Feature Source string fsId = "Library://Samples/Sheboygan/Data/VotingDistricts.FeatureSource"; //The place we'll store the layer definition string layerId = "Session:" + conn.SessionID + "//ThemedVotingDistricts.LayerDefinition"; CreateDistrictsLayer(conn, fsId, layerId); ILayerDefinition layerDef = (ILayerDefinition)conn.ResourceService.GetResource(layerId); RuntimeMapLayer layer = mpSvc.CreateMapLayer(rtMap, layerDef); layer.Name = "ThemedDistricts"; layer.Group = ""; layer.LegendLabel = "Themed Districts"; 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 = "Themed districts layer added"; } rtMap = mpSvc.OpenMap(rtMapId); DumpMap(rtMap); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string agent = ConfigurationManager.AppSettings["MapAgentUrl"]; string mapName = Request.Params["MAPNAME"]; string session = Request.Params["SESSION"]; IServerConnection conn = ConnectionProviderRegistry.CreateConnection( "Maestro.Http", "Url", agent, "SessionId", session); IMappingService mpSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping); string rtMapId = "Session:" + conn.SessionID + "//" + mapName + ".Map"; RuntimeMap rtMap = mpSvc.OpenMap(rtMapId); int layerIndex = rtMap.Layers.IndexOf("Parcels"); RuntimeMapLayer layer = rtMap.Layers[layerIndex]; //Here is now the layer replacement technique works: // //We take the Layer Definition content referenced by the old layer //Modify the filter in this content and save it to a new resource id //We then create a replacement layer that points to this new resource id //and set the public properties to be identical of the old layer. // //Finally we then remove the old layer and put the replacement layer in its //place, before saving the runtime map. ILayerDefinition ldf = (ILayerDefinition)conn.ResourceService.GetResource(layer.LayerDefinitionID); IVectorLayerDefinition vl = (IVectorLayerDefinition)ldf.SubLayer; //Sets the layer filter vl.Filter = "RNAME LIKE 'SCHMITT%'"; if (Request.Params["RESET"] == "1") { vl.Filter = ""; } //Save this modified layer under a different resource id string ldfId = "Session:" + conn.SessionID + "//ParcelsFiltered.LayerDefinition"; conn.ResourceService.SaveResourceAs(ldf, ldfId); //Note that SaveResourceAs does not modify the ResourceID of the resource we want to save //so we need to update it here ldf.ResourceID = ldfId; //Create our replacement layer and apply the same properties from the old one RuntimeMapLayer replace = mpSvc.CreateMapLayer(rtMap, ldf); replace.ExpandInLegend = layer.ExpandInLegend; replace.Group = layer.Group; replace.LegendLabel = layer.LegendLabel; replace.Name = layer.Name; replace.Selectable = layer.Selectable; replace.ShowInLegend = layer.ShowInLegend; replace.Visible = layer.Visible; //Remove the old layer and put the new layer at the same position (thus having the //same draw order) rtMap.Layers.RemoveAt(layerIndex); rtMap.Layers.Insert(layerIndex, replace); replace.ForceRefresh(); rtMap.Save(); if (Request.Params["RESET"] == "1") { lblMessage.Text = "Layer filter has been reset"; resetLink.Visible = false; } else { lblMessage.Text = "Layer filter has been set (to RNAME LIKE 'SCHMITT%')"; resetLink.Attributes["href"] = "ModifyParcelsFilter.aspx?MAPNAME=" + mapName + "&SESSION=" + session + "&RESET=1"; } Page.ClientScript.RegisterStartupScript( this.GetType(), "load", "<script type=\"text/javascript\"> window.onload = function() { parent.parent.Refresh(); } </script>"); } }
internal bool GetVisibilityFlag(RuntimeMapLayer layer) => layer.IsVisibleAtScale(_map.ViewScale);
static XmlElement encodeRuntimeMapLayer(XmlDocument doc, RuntimeMapLayer rmaplayer) { XmlElement e = null; if (rmaplayer != null) { e = doc.CreateElement("maplayer"); e.SetAttribute("layer", rmaplayer.getBuildLayer().getName()); e.SetAttribute("searchlayer", rmaplayer.getSearchLayer().getName()); e.SetAttribute("visible", (rmaplayer.getVisible() ? "true" : "false")); e.SetAttribute("searchable", (rmaplayer.getSearchable() ? "true" : "false")); } return e; }
static RuntimeMapLayer decodeRuntimeMapLayer(XmlElement e, Project proj) { RuntimeMapLayer layer = null; if (e != null) { layer = new RuntimeMapLayer(); layer.setBuildLayer(proj.getLayer(e.GetAttribute("layer"))); layer.setSearchLayer(proj.getLayer(e.GetAttribute("searchlayer"))); if (e.GetAttribute("searchable") == "true") layer.setSearchable(true); if (e.GetAttribute("visible") == "false") layer.setVisible(false); } return layer; }
private void drawOrderCtrl_LayerSelected(object sender, RuntimeMapLayer layer) { propGrid.SelectedObject = new LayerNodeMetadata(layer); }
public DrawOrderDisplayItem(RuntimeMapLayer layer) { this.Label = $"{layer.Name} ({layer.LegendLabel})"; //NOXLATE this.Decorator = new LayerDecorator(layer); }
protected void Page_Load(object sender, EventArgs e) { string agent = ConfigurationManager.AppSettings["MapAgentUrl"]; string mapName = Request.Params["MAPNAME"]; string layerId = Request.Params["LAYERID"]; string id = HttpUtility.UrlDecode(Request.Params["ID"]); 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 + "//" + mapName + ".Map"; RuntimeMap rtMap = mpSvc.OpenMap(rtMapId); RuntimeMapLayer layer = rtMap.Layers.GetByObjectId(layerId); //The values returned are in the same order as the array from the IdentityProperties object[] values = layer.ParseSelectionValues(id); PropertyInfo[] idProps = layer.IdentityProperties; //Having decoded the identity property values and knowing what names they are from the //RuntimeMapLayer, construct the selection filter based on these values. // //This sample assumes the Sheboygan dataset and so all identity property values are //known to be only numeric or strings. If this is not the case for you, use the Type //property in PropertyInfo to determine how to construct the filter string[] conditions = new string[idProps.Length]; for (int i = 0; i < idProps.Length; i++) { conditions[i] = idProps[i].Name + " = " + values[i].ToString(); } //OR all the conditions together to form our final filter string selFilter = string.Join(" OR ", conditions); //Execute the query IFeatureReader reader = conn.FeatureService.QueryFeatureSource( layer.FeatureSourceID, layer.QualifiedClassName, selFilter); //Use a StringBuilder because we are doing a lot of concatentation here StringBuilder sb = new StringBuilder(); //Collect the field names string[] fieldNames = new string[reader.FieldCount]; for (int i = 0; i < reader.FieldCount; i++) { fieldNames[i] = reader.GetName(i); } int count = 0; //Write out the attribute table while (reader.ReadNext()) { sb.Append("<table border='1'>"); for (int i = 0; i < fieldNames.Length; i++) { //Just like the MgFeatureReader, you must test for null before //attempting extraction of values, but unlike MgFeatureReader this //offers an indexer property that returns System.Object which allows //a nice and easy way to string coerce all property values. sb.Append("<tr>"); sb.Append("<td><strong>" + fieldNames[i] + "</strong></td>"); sb.Append("<td>" + (reader.IsNull(i) ? "(null)" : reader[i]) + "</td>"); sb.Append("</tr>"); } sb.Append("</table>"); count++; } content.InnerHtml = sb.ToString(); lblMessage.Text = "Showing attributes of " + count + " features"; reader.Close(); }
internal LayerNodeMetadata(RuntimeMapLayer layer, bool bInitiallySelectable) { base.IsGroup = false; this.Layer = layer; this.IsSelectable = (layer != null) ? layer.Selectable : false; this.DrawSelectabilityIcon = (layer != null && bInitiallySelectable); this.WasInitiallySelectable = bInitiallySelectable; this.LayerDefinitionContent = null; this.Checkable = (layer.Type != RuntimeMapLayer.kBaseMap); _themeNodes = new Dictionary<ThemeCategory, List<LayerThemeNodeMetadata>>(); _defaultIcons = new Dictionary<ThemeCategory, Image>(); }
/// <summary> /// Initializes a new instance of the LayerNodeMetadata class /// </summary> /// <param name="layer"></param> public LayerNodeMetadata(RuntimeMapLayer layer) : this(layer, layer.Selectable) { }
private void OnLayerSelected(RuntimeMapLayer layer) { this.LayerSelected?.Invoke(this, layer); }
public LayerDecorator(RuntimeMapLayer layer) { _layer = layer; }
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); }