Function: After you enter the longitude and latitude coordinates in the two edit boxes, click the button to display a point on the map of the dialog box, when you enter a coordinate between longitude and latitude, a line connecting two points is displayed, and so on .... Finally, the track of the vertex is displayed!
// The code below the mouse drop event can be placed in the Timer
// Or execute other events here in the mouse event for convenient collection (because there is no data input interface)
// Defined in the header file:
CArray <double, double> XI; // used for mobile phone longitude and latitude coordinates
CArray <double, double> YI;
Void C *** Dlg: OnMouseDownMap1 (short Button, short Shift, float X, float Y)
{
Double Xm, Ym;
M_ctrlMapX.ConvertCoord (& X, & Y, & Xm, & Ym, miScreenToMap); // convert the screen coordinates of Coordinate Conversion to map coordinates.
XI. Add (Xm );
YI. Add (Ym );
Int Nm = XI. GetSize (); // get the length of the dynamic array of coordinate points
If (Nm> 1)
{
//------------------------------------------------------------------------------
Double Xb = XI [Nm-2];
Double Yb = YI [Nm-2];
//------------------------------------------------------------------------------
CMapXPoints pts;
Pts. CreateDispatch (pts. GetClsid ());
Pts. AddXY (Xb, Yb );
Pts. AddXY (Xm, Ym );
//------------------------------------------------------------------------------
CMapXLayers allLr = m_ctrlMapX.GetLayers ();
CMapXLayer staLr = allLr. GetAnimationLayer ();
Stalr. beginaccess (miaccessreadwrite );
//------------------------------------------------------------------------------
Cmapxfeature ft;
Ft. createdispatch (FT. getclsid ());
Ft. Attach (m_ctrlmapx.getdispatch (false ));
// When you create an element, if this sentence is missing, "the independent feature object is not attached to the map. Featureattach () error before other feature methods or attributes
Ft. settype (mifeaturetypeline );
Ft. getstyle (). setlinecolor (0xff0000 );
Ft. GetStyle (). SetLineStyle (1 );
Ft. GetStyle (). SetLineWidth (1 );
Ft. GetParts (). Add (pts );
StaLr. AddFeature (LPDISPATCH) ft); // Add to target Layer
//------------------------------------------------------------------------------
// CMapXPoint ptd; // This piece of code can be uncommented. comment out the following code to see if the difference is that different types of symbols are used to represent points.
// Ptd. CreateDispatch (ptd. GetClsid ());
// Ptd. Set (Xm, Ym );
//
// CMapXFeature ftd;
// Ftd. CreateDispatch (ftd. GetClsid ());
// Ftd. Attach (m_ctrlMapX.GetDispatch (FALSE ));
//
// Ftd. SetType (miFeatureTypeSymbol );
// Ftd. GetStyle (). SetSymbolType (2 );
// Ftd. GetStyle (). SetSymbolBitmapSize (4 );
// Ftd. GetStyle (). SetSymbolBitmapColor (0x0000FF );
// Ftd. SetPoint (ptd );
//
// Stalr. addfeature (lpdispatch) FTD );
//-----------------------------------------------------------------------------
Cmapxpoint PTD;
PTD. createdispatch (PTD. getclsid ());
PTD. Set (XM, ym );
Cmapxfeature FTD;
FTD. createdispatch (FTD. getclsid ());
FTD. Attach (m_ctrlmapx.getdispatch (false ));
FTD. settype (mifeaturetypesymbol );
Ftd. GetStyle (). SetSymbolType (miSymbolTypeTrueTypeFont );
Ftd. GetStyle (). SetSymbolFontBackColor (0x0000FF );
Ftd. GetStyle (). SetSymbolCharacter (34); // you can change the number to indicate the symbol. You need to check the definition here.
CY sz; sz. Hi = 0; sz. int64 = 52500; sz. Lo = 52500; // The text size setting is also strange.
Ftd. GetStyle (). GetSymbolFont (). SetSize (sz );
Ftd. GetStyle (). GetSymbolFont (). SetName ("Mapinfo symbols ");
Ftd. GetStyle (). SetSymbolFontShadow (TRUE );
Ftd. GetStyle (). SetSymbolFontRotation (0 );
Ftd. GetStyle (). SetSymbolFontHalo (FALSE );
Ftd. GetStyle (). SetSymbolFontColor (0x0000FF );
Ftd. SetPoint (ptd );
StaLr. AddFeature (LPDISPATCH) ftd );
StaLr. EndAccess ();
} Else {
//------------------------------------------------------------------------------
CMapXLayers allLr = m_ctrlMapX.GetLayers ();
Cmapxlayer stalr = alllr. getanimationlayer ();
Stalr. beginaccess (miaccessreadwrite );
//------------------------------------------------------------------------------
// Cmapxpoint PTD;
// PTD. createdispatch (PTD. getclsid ());
// PTD. Set (XM, ym );
//
// Cmapxfeature FTD;
// FTD. createdispatch (FTD. getclsid ());
// FTD. Attach (m_ctrlmapx.getdispatch (false ));
//
// FTD. settype (mifeaturetypesymbol );
// FTD. getstyle (). setsymboltype (2 );
// FTD. getstyle (). setsymbolbitmapsize (4 );
// FTD. getstyle (). setsymbolbitmapcolor (0x0000ff );
// FTD. setpoint (PTD );
//
// Stalr. addfeature (lpdispatch) FTD );
//-----------------------------------------------------------------------------
CMapXPoint ptd;
Ptd. CreateDispatch (ptd. GetClsid ());
Ptd. Set (Xm, Ym );
CMapXFeature ftd;
Ftd. CreateDispatch (ftd. GetClsid ());
Ftd. Attach (m_ctrlMapX.GetDispatch (FALSE ));
Ftd. SetType (miFeatureTypeSymbol );
Ftd. GetStyle (). SetSymbolType (miSymbolTypeTrueTypeFont );
FTD. getstyle (). setsymbolfontbackcolor (0x0000ff );
FTD. getstyle (). setsymbolcharacter (34); // you can change the number to indicate the symbol. You need to check the definition here.
Cy SZ; Sz. Hi = 0; Sz. int64 = 52500; Sz. Lo = 52500; // The text size setting is also strange.
FTD. getstyle (). getsymbolfont (). setsize (sz );
FTD. getstyle (). getsymbolfont (). setname ("MapInfo symbols ");
FTD. getstyle (). setsymbolfontshadow (true );
FTD. getstyle (). setsymbolfontrotation (0 );
Ftd. GetStyle (). SetSymbolFontHalo (FALSE );
Ftd. GetStyle (). SetSymbolFontColor (0x0000FF );
Ftd. SetPoint (ptd );
StaLr. AddF
Eature (LPDISPATCH) ftd); staLr. EndAccess ();}}