Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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
 
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 10-May-13 23:17pm
Edited 11-May-13 1:12am
v4
Comments
Richard MacCutchan at 11-May-13 4:26am
   
Please show your code, no one can guess what it is doing.
nabeeel ahmed at 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 at 11-May-13 6:25am
   
Sorry, but I have no knowledge of MapXtreme so I could not comment.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Sometime, taking some time to actually read the documentation helps!
 
Check this out: MapXtreme Developer's Guide. See page 253 and onwards
  Permalink  
Comments
nabeeel ahmed at 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
0 OriginalGriff 195
1 ProgramFOX 130
2 Maciej Los 105
3 Sergey Alexandrovich Kryukov 105
4 Afzaal Ahmad Zeeshan 82
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web01 | 2.8.1411022.1 | Last Updated 11 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100