MAPX development target Trajectory display core code (VC + +)

Source: Internet
Author: User
One, the affirmation variableCMAPX m_ctrlmapx;            Cmapxlayer M_objlayer;          Moving target layer Cmapxlayer m_tracelayer;   The target trajectory layer cmapxlayer m_scalebarlayer;  Scale layer Cmapxfeature m_objft;       Double M_lfcenterlon;         Map center longitude double M_lfcenterlat; Map Center latitude Cmapxfeature M_objtrackft[maxnuminemap]; Second, create a map controlCRect RC;  GetClientRect (&AMP;RC); M_ctrlmapx. Create(Null,ws_visible, RC, this, idc_map);  M_ctrlmapx.setcurrenttool (Mipantool); Char Geoname[max_path]; GetCurrentDirectory (Max_path,geoname); strcat (Geoname, "/map/asia.gst"); String 3 m_ctrlmapx. Setgeoset(geoname);//Set map name M_ctrlmapx.settitletext (""); M_ctrlmapx. Setmapunit(miunitkilometer)//Set map unit M_ctrlmapx.setpaperunit (mipaperunitkilometer); M_scalebarlayer = M_ctrlmapx.getlayers (). Adduserdrawlayer("scale", 1);//Add User display layer M_ctrlmapx.setautoredraw (TRUE); Third, create the target trajectory layer  m_objlayer = M_ctrlmapx.getlayers (). Createlayer ("Goal", NULL, 1, 32);  m_ctrlmapx.getlayers (). Setanimationlayer (M_objlayer);/set the layer to animation layer  m_objlayer.setselectable (FALSE);//Set this layer target is not selectable  m_ Objlayer.setautolabel (TRUE);/set this layer target to automatically callout  m_objlayer.getlabel (). Setlinetype (Milinetypenone);//Set Callout linear  m_objlayer.getlabel (). SetPosition (MIPOSITIONTR);//Set Callout position  m_objlayer.getlabel (). SetOffset (2);/Set callout offset  m_objlayer.setoverridestyle (TRUE);//All Feature in this layer use the same style,*** key point, when using different style, the parameter is false*** string 1  m_objlayer.getlabel (). GetStyle (). Settextfontcolor (micolorred);//Set Callout color  m_objlayer.getlabel (). Setoverlap (TRUE);//allow annotations to overwrite  m_objlayer.getstyle (). Getsymbolfont (). SetName ("Mapinfo symbols");//Set the font  m_objlayer.getstyle () used by the symbol feature. Setsymbolcharacter (53);//Set the character  m_objlayer.getstyle () used by the symbol feature. Setsymbolfontcolor (RGB (255,0,0));//Set the color  m_objlayer.getstyle () used by the symbol feature. Setlinewidth (1)//Set line width of linear feature  m_objLayer.setdrawlabelsafter (TRUE);//Draw callout After all layers have been drawn Iv. Creating the target trajectory layerM_tracelayer = M_ctrlmapx.getlayers ().  Createlayer ("Trajectory", NULL, 2, 32); M_ctrlmapx.getlayers ().  Setanimationlayer (M_tracelayer);  M_tracelayer.setselectable (FALSE); M_tracelayer.setdrawlabelsafter (TRUE);//affects key to annotation refresh v. Response Ondrawuserlayer Draw scale layer Six, change the target position in the timer Vii. refreshing electronic maps  m_objlayer.beginaccess (miaccessreadwrite);//significantly reduce CPU overhead  m_tracelayer.beginaccess (miAccessReadWrite); /significantly reduce CPU overhead  for (int i=0;i<maxnuminemap; i++)  { //Set Target location   sobjectinemap[i].ft. GetPoint (). Set (sgispoint[i][0].x, SGISPOINT[I][0].Y);   sobjectinemap[i].ft. Update ();      //Set Target trajectory  //empty time to create target trajectory object   if (m_objtrackft[i]==null)   {   Cmapxfeatur e ft;    ft. CreateDispatch (ft.) Getclsid ());    ft. Attach (M_ctrlmapx.getdispatch (FALSE));    ft. SetType (Mifeaturetypeline);    ft. GetStyle (). Setlinecolor (colors[i%12]);    ft. GetStyle (). Setlinestyle (1);//77-rails (reference help)    ft. GetStyle (). Setlinewidth (2);    cmapxpoints pts;    pts. CreateDispatch (pts. Getclsid ());   //Add coordinate Data    pts. ADDXY (sgispoint[i][1].x, SGISPOINT[I][1].Y);    pts. ADDXY (sgispoint[i][0].x, SGISPOINT[I][0].Y);    ft. GetParts (). Add(pts);   //Add to target layer    m_objtrackft[i] = m_tracelayer.addfeature ((lpdispatch) ft); String 6  }   else   {  //Update target trajectory object    m_objtrackft[i]. GetParts (). Item (1). ADDXY (sgispoint[i][0].x, SGISPOINT[I][0].Y);    M_objtrackft[i]. Update ();  }   Sgispoint[i][1] = sgispoint[i][0];  }  m_tracelayer.endaccess ();  m_objlayer.endaccess ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.