// Save the state public override void SaveState() { string mapAlias = ParamsDictionary[ActiveMapAliasKey] as string; Map map = GetMapObj(mapAlias); if (map == null) { return; } SaveZoomCenterState(map); //ManualSerializer.SaveMapXtremeObjectIntoHttpSession(map.Layers, "Layers"); ManualSerializer.SaveMapXtremeObjectIntoHttpSession(MapInfo.Engine.Session.Current.Selections.DefaultSelection, GetKey("Selection")); // Needs this because StateManger doens't have proper function to save them. // Need to serialize the temp table first since the temp layer is based on it. if (StateManager.IsManualState()) { MapInfo.Mapping.FeatureLayer fLyr = (MapInfo.Mapping.FeatureLayer)map.Layers[Constants.TempLayerAlias]; MapInfo.Data.Table tbl = (fLyr != null) ? fLyr.Table : null; if (fLyr != null) { ManualSerializer.SaveMapXtremeObjectIntoHttpSession(tbl, "tempTable"); ManualSerializer.SaveMapXtremeObjectIntoHttpSession(fLyr, "tempLayer"); } } }
// Creates a simple theme using the default values private void SimpleTheme(Map map) { // Get table from the feature layer MapInfo.Mapping.FeatureLayer mexicoLayer = map.Layers["mexico"] as MapInfo.Mapping.FeatureLayer; MapInfo.Data.Table mexicoTable = mexicoLayer.Table; // Create the theme GraduatedSymbolTheme theme = new GraduatedSymbolTheme(mexicoTable, "Pop_90"); // Create the theme layer ObjectThemeLayer themeLayer = new ObjectThemeLayer("Population1990", "Population1990", theme); // Add theme layer to the map map.Layers.Add(themeLayer); }
// Creates a theme with a non-default symbol private void CustomPositiveSymbolTheme(Map map) { // Get table from the feature layer MapInfo.Mapping.FeatureLayer mexicoLayer = map.Layers["mexico"] as MapInfo.Mapping.FeatureLayer; MapInfo.Data.Table mexicoTable = mexicoLayer.Table; // Create the theme GraduatedSymbolTheme theme = new GraduatedSymbolTheme(mexicoTable, "Pop_90"); // Replace the default symbol of the theme theme.PositiveSymbol = new MapInfo.Styles.SimpleVectorPointStyle(35, Color.Blue, 36); // Create the theme layer ObjectThemeLayer themeLayer = new ObjectThemeLayer("Population1990", "Population1990", theme); // Add theme layer to the map map.Layers.Add(themeLayer); }
// Creates a theme with a custom DataValueAtSize property private void DataValueAtSizeTheme(Map map) { // Get table from the feature layer MapInfo.Mapping.FeatureLayer mexicoLayer = map.Layers["mexico"] as MapInfo.Mapping.FeatureLayer; MapInfo.Data.Table mexicoTable = mexicoLayer.Table; // Create the theme GraduatedSymbolTheme theme = new GraduatedSymbolTheme(mexicoTable, "Pop_90"); // Decreasing DataValueAtSize value will increase the size of the symbols. theme.DataValueAtSize /= 4; // Create the theme layer ObjectThemeLayer themeLayer = new ObjectThemeLayer("Population1990", "Population1990", theme); // Add theme layer to the map map.Layers.Add(themeLayer); }
// Creates a theme whose symbol sizes are graduated logarithmically private void GraduateByLogTheme(Map map) { // Get table from the feature layer MapInfo.Mapping.FeatureLayer mexicoLayer = map.Layers["mexico"] as MapInfo.Mapping.FeatureLayer; MapInfo.Data.Table mexicoTable = mexicoLayer.Table; // Create the theme GraduatedSymbolTheme theme = new GraduatedSymbolTheme(mexicoTable, "Pop_90"); // Graduate the size logarithmically theme.GraduateSizeBy = GraduateSizeBy.Log; // Create the theme layer ObjectThemeLayer themeLayer = new ObjectThemeLayer("Population1990", "Population1990", theme); // Add theme layer to the map map.Layers.Add(themeLayer); }
protected void Page_Load(object sender, System.EventArgs e) { MapInfo.Mapping.Map myMap = GetMapObj(); if (Session.IsNewSession) { AppStateManager stateManager = new AppStateManager(); stateManager.ParamsDictionary[AppStateManager.ActiveMapAliasKey] = this.MapControl1.MapAlias; MapInfo.WebControls.StateManager.PutStateManagerInSession(stateManager); // Add customized web tools // Below line will put controlModel into HttpSessionState. MapInfo.WebControls.MapControlModel controlModel = MapControlModel.SetDefaultModelInSession(); controlModel.Commands.Add(new AddPinPointCommand()); controlModel.Commands.Add(new ClearPinPointCommand()); controlModel.Commands.Add(new ModifiedRadiusSelectionCommand()); /****** Set the initial state of the map *************/ // Clear up the temp layer left by other customer requests. if (myMap != null) { if (myMap.Layers[SampleConstants.TempLayerAlias] != null) { myMap.Layers.Remove(SampleConstants.TempLayerAlias); } } // Need to clean up "dirty" temp table left by other customer requests. MapInfo.Engine.Session.Current.Catalog.CloseTable(SampleConstants.TempTableAlias); // Need to clear the DefautlSelection. MapInfo.Engine.Session.Current.Selections.DefaultSelection.Clear(); // Creat a temp table and AddPintPointCommand will add features into it. MapInfo.Data.TableInfoMemTable ti = new MapInfo.Data.TableInfoMemTable(SampleConstants.TempTableAlias); // Make the table mappable ti.Columns.Add(MapInfo.Data.ColumnFactory.CreateFeatureGeometryColumn(myMap.GetDisplayCoordSys())); ti.Columns.Add(MapInfo.Data.ColumnFactory.CreateStyleColumn()); MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti); // Create a new FeatureLayer based on the temp table, so we can see the temp table on the map. myMap.Layers.Insert(0, new FeatureLayer(table, "templayer", SampleConstants.TempLayerAlias)); // This step is needed because you may get a dirty map from mapinfo Session.Current which is retrived from session pool. myMap.Zoom = new MapInfo.Geometry.Distance(25000, MapInfo.Geometry.DistanceUnit.Mile); myMap.Center = new MapInfo.Geometry.DPoint(27775.805792979896, -147481.33999999985); } MapInfo.WebControls.StateManager.GetStateManagerFromSession().RestoreState(); }
// Save the state public override void SaveState() { string mapAlias = this.ParamsDictionary[AppStateManager.ActiveMapAliasKey] as String; MapInfo.Mapping.Map myMap = GetMapObj(mapAlias); if (myMap == null) { return; } // Note: for performance reasons, only save the map's center and zoom. AppStateManager.SaveZoomCenterState(myMap); // Get the workingLayerName saved in WebForm1.aspx page_load. string workingLayerName = this.ParamsDictionary["WorkingLayerName"] as String; // Save the map's Working table and layer MapInfo.Mapping.FeatureLayer workingLayer = (MapInfo.Mapping.FeatureLayer)myMap.Layers[workingLayerName]; MapInfo.Data.Table workingTable = workingLayer != null ? workingLayer.Table : null; ManualSerializer.SaveMapXtremeObjectIntoHttpSession(workingTable, "WorkingTable"); ManualSerializer.SaveMapXtremeObjectIntoHttpSession(workingLayer, "WorkingLayer"); }
// Creates a theme that shows symbols for negative values. // Also uses the NumericNull property to hide the symbol of // the greatest theme value. private void NegativeValueTheme(Map map) { // Get table from the feature layer MapInfo.Mapping.FeatureLayer mexicoLayer = map.Layers["mexico"] as MapInfo.Mapping.FeatureLayer; MapInfo.Data.Table mexicoTable = mexicoLayer.Table; // Add a temporary column to the mexico table, // calulating the difference between Pop_90 and Pop_80 MapInfo.Data.Columns tempColumns = new MapInfo.Data.Columns(); tempColumns.Add(new MapInfo.Data.Column("CarsMinusTrucks", "(Cars_91-Trucks_91)")); mexicoTable.AddColumns(tempColumns); // Create the theme GraduatedSymbolTheme theme = new GraduatedSymbolTheme(mexicoTable, "CarsMinusTrucks"); // Show Negative symbols theme.ShowNegativeSymbol = true; // Setup symbols theme.PositiveSymbol = new MapInfo.Styles.SimpleVectorPointStyle(35, Color.Blue, 18); theme.NegativeSymbol = new MapInfo.Styles.SimpleVectorPointStyle(35, Color.Red, 36); // Get the larget value in the theme column MapInfo.Data.MIDataReader reader = mexicoTable.ExecuteReader("MAX(CarsMinusTrucks)"); reader.MoveNext(); double maxValue = reader.GetDouble(0); reader.Dispose(); // Setup the numeric null value to exclude the largest value theme.NumericNull = maxValue; theme.HasNumericNull = true; // These end up being small values, so use the DataValueAtSize // property to increase the size of the symbols theme.DataValueAtSize = 50000; // Create the theme layer ObjectThemeLayer themeLayer = new ObjectThemeLayer("CarOrTruck", "CarOrTruck", theme); // Add theme layer to the map map.Layers.Add(themeLayer); }