Simple GIS programming with VC

zhaozj2021-02-16  57

Component GIS adopts standard component technology and supports current popular programming languages ​​such as VC, C #, Delphi and other development platforms, so that developers have saved the study of specialized GIS development languages, making it simpler.

I have recently been developed with VC6.0, and the specific GIS development platform is Beijing Chao Geographic Information Technology Co., Ltd. (http://www.supermap.com.cn) Provides SuperMap Object.

First, create a dialog-based MFC application, named MAP, and hold the default option.

Then, add the SuperMap control to the project, first select the Components and Controls in Add to Project in the Project menu, join the SuperMap Control and SuperWorkspace Control in the Register ActiveX Controls folder, join the two controls to the dialog box. Adjust the SuperMap control appropriately.

The add variables now add variables for SuperMap Control and SuperWorkspace Control controls, respectively, M_SUPERMAP and M_SUPERWORKSPACE. The following code will then be added in the function of the initialization dialog (before returntrue):

// open the map and show CsoDataSource objDataSource; CsoDatasets objDataSets; long Index; // establish a working space and a data source contact m_SuperMap.Connect (m_SuperWorkspace.GetHandle ()); // Open Data Source objDataSource = m_SuperWorkspace.OpenDataSource ( "C: //Myproject//World.sdb" ,"ward" ,0, false); if (! ObjDataSource) {MessageBox ("Open data source error!"); Exit (0);} // get the data set objDataSets = ObjDataSource .GetdataSets (); // Add layer for (index = 1; index <= objDataSets.getCount (); index ) {m_supermap.getlayers (). Adddatats (ObjdataSets.Getitem (Colevariant (Index)), False); // Refresh, display m_supermap.refresh ();

Where the OpenDataSource ("C: //MyProject//World.sdb", "World", 0, false is the full path name of the data source file, the second is the data source name, the third For the data source engine type, the fourth is whether it is read only. The first parameter of AddDataSet is the data set object to be added, and the second parameter indicates whether the data set is added to the top layer of SuperMap. True is added to the top; FALSE is added to the bottom.

Add the above code, compile execution, you can see your World map display in the dialog box.

转载请注明原文地址:https://www.9cbs.com/read-12756.html

New Post(0)