public MapForm1(MapInfo.Mapping.Map map) { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // mapControl1.Map = map; }
private void showPointOnSearchTableMap(double x, double y) { MapInfo.Mapping.Map map = Session.Current.MapFactory.CreateEmptyMap(System.IntPtr.Zero, new Size(10, 10)); MapInfo.Mapping.FeatureLayer searchLayer = new MapInfo.Mapping.FeatureLayer(_searchTable); map.Layers.Add(searchLayer); MapForm1 mapForm = new MapForm1(map); Form parentForm = this; // create a temp table and add a featurelayer for it (use map alias as table alias) // make the table hidden (maybe) MapInfo.Geometry.CoordSys coordSys = map.GetDisplayCoordSys(); TableInfoMemTable ti = new TableInfoMemTable("temp"); ti.Temporary = true; // add object column Column col; col = new GeometryColumn(coordSys); // specify coordsys for object column col.Alias = "obj"; col.DataType = MIDbType.FeatureGeometry; ti.Columns.Add(col); // add style column col = new Column(); col.Alias = "MI_Style"; col.DataType = MIDbType.Style; ti.Columns.Add(col); Table pointTable = Session.Current.Catalog.CreateTable(ti); // I am using a Point example here. You can create a rectangle instead MapInfo.Geometry.FeatureGeometry g = new MapInfo.Geometry.Point(coordSys, x, y); MapInfo.Styles.SimpleVectorPointStyle vs = new MapInfo.Styles.SimpleVectorPointStyle(37, System.Drawing.Color.Red, 14); MapInfo.Styles.CompositeStyle cs = new MapInfo.Styles.CompositeStyle(vs); MICommand cmd = _miConnection.CreateCommand(); cmd.Parameters.Add("geometry", MIDbType.FeatureGeometry); cmd.Parameters.Add("style", MIDbType.Style); cmd.CommandText = "Insert Into temp (obj,MI_Style) values (geometry,style)"; cmd.Prepare(); cmd.Parameters[0].Value = g; cmd.Parameters[1].Value = cs; int nchanged = cmd.ExecuteNonQuery(); cmd.Dispose(); map.Layers.Add(new MapInfo.Mapping.FeatureLayer(pointTable)); // another way: Map.Load(new MapTableLoader(table)); // make the map encompass the entire search layer map.SetView(searchLayer); // size the map form mapForm.Size = new Size(500, 500); //Show the form like a dialog (modal) mapForm.ShowDialog(parentForm); pointTable.Close(); }