Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends:

I am using MapXtreme 2008 With C# I have very basic problem I need to create text on a specific X,Y. I am reading and trying but not able to do it.
I am able to insert images on a specific X,Y but not text I am really embraced with this problem. can anyone help me.
please help me.


Regards:

Nabeel Ahmad.


please see the code

C#
private void MapInfo_Geometry_LegacyText(double X1,double Y1, string MyText)
{
    try
    {
        Feature ftr;
        // Create a CoordSys for the Geometry to use.
        MapInfo.Geometry.CoordSysFactory factory = Session.Current.CoordSysFactory;
        MapInfo.Geometry.CoordSys csysWGS84 = factory.CreateCoordSys("EPSG:4326");

        double X2 = X1 + 0.01555;
        double Y2 = Y1 - 0.00173;
        DPoint pt = new MapInfo.Geometry.DPoint(X1, Y1);
        // Create LegacyText            
        MapInfo.Geometry.DRect rect = new MapInfo.Geometry.DRect(X1, Y1, X2, Y2);
        MapInfo.Geometry.LegacyText ltxt = new MapInfo.Geometry.LegacyText(csysWGS84, rect, MyText);

        double X = double.Parse(label_X.Text);
        double Y = double.Parse(label_Y.Text);

        TextFactory.CreateLegacyText(mapControl_Fs.Map.GetDisplayCoordSys(), pt, Alignment.TopCenter, label_INCIDENT_ID_1.Text, mapControl_Fs.Map, new MapInfo.Styles.Font("Microsoft Sans Serif", 20));
       
        MapInfo.Geometry.FeatureGeometry g = new MapInfo.Geometry.Ellipse(csysWGS84, pt, 0.003, 0.003, DistanceUnit.Kilometer, DistanceType.Spherical);

        MapInfo.Styles.SimpleInterior sis = new MapInfo.Styles.SimpleInterior(2, Color.Red);
        MapInfo.Styles.LineWidth lw = new MapInfo.Styles.LineWidth(1, MapInfo.Styles.LineWidthUnit.Point);
        MapInfo.Styles.SimpleLineStyle sl = new MapInfo.Styles.SimpleLineStyle(lw, 3, Color.Empty);
        MapInfo.Styles.AreaStyle ar = new MapInfo.Styles.AreaStyle(sl, sis);

        MapInfo.Styles.CompositeStyle cs = new MapInfo.Styles.CompositeStyle(ar, null, null, null);
        MapInfo.Mapping.FeatureOverrideStyleModifier fsm = new MapInfo.Mapping.FeatureOverrideStyleModifier("a", cs);
        MapInfo.Data.MIConnection conn = new MapInfo.Data.MIConnection();
        MapInfo.Data.Table tbl;
        conn.Open();

        //Here I need to Make sure that the temporary table does not exist before creating.

        tbl = conn.Catalog.GetTable("tbl_PointAdd");
        if (tbl != null)
            conn.Catalog.CloseTable("tbl_PointAdd");

        MapInfo.Data.TableInfoMemTable ti = new MapInfo.Data.TableInfoMemTable("tbl_PointAdd");
        ti.Columns.Add(MapInfo.Data.ColumnFactory.CreateFeatureGeometryColumn(mapControl_Fs.Map.GetDisplayCoordSys()));
        ti.Columns.Add(MapInfo.Data.ColumnFactory.CreateStyleColumn());
        ti.Temporary = true;
        tbl = conn.Catalog.CreateTable(ti);
        MapInfo.Mapping.FeatureLayer lyr = new MapInfo.Mapping.FeatureLayer(tbl, "tbl_PointAnimation");
        mapControl_Fs.Map.Layers.Add(lyr);
        MapInfo.Data.MICommand cmd = conn.CreateCommand();
        ftr = new MapInfo.Data.Feature(g, cs);
        tbl.InsertFeature(ftr);
        lyr.VolatilityHint = MapInfo.Mapping.LayerVolatilityHint.Animate;
        lyr.Modifiers.Append(fsm);
        conn.Close();
    }
    catch (Exception ex) 
    {
        MessageBox.Show(ex.StackTrace.ToString());
    }
}
Posted
Updated 11-May-13 0:12am
v4
Comments
Richard MacCutchan 11-May-13 4:26am    
Please show your code, no one can guess what it is doing.
nabeeel ahmed 11-May-13 6:24am    
Mr. Richard: Actually I do not know that I am using right method to insert the text on a specific XY, if you know can you please send me a piece of code to insert text on the map at specific coordinate. Thank you, Regards: Nabeel Ahmad
Richard MacCutchan 11-May-13 6:25am    
Sorry, but I have no knowledge of MapXtreme so I could not comment.

1 solution

Sometime, taking some time to actually read the documentation helps!

Check this out: MapXtreme Developer's Guide. See page 253 and onwards
 
Share this answer
 
Comments
nabeeel ahmed 11-May-13 7:37am    
Venerable Ryan Zahra: sure I have read many time as well as I have also getting knowledge from this website http://testdrive.mapinfo.com/techsupp/miprod.nsf/8248bf2b72f6949585257125006b035a/02ca9fa0af9ae5bb85256e9e00603663?OpenDocument
but I am not succeeded. I do not know where I am wrong. anyhow if someone has the answer or piece of code for some lines I will appreciate it.
Thank You,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900