Getting Started with Global Mapper SDK

How to Load a Layer:

Once the Global Mapper SDK is installed, there will be some documentation and sample code inside the SDK's directory to help you get started. By default, this material will be installed to the "C:\GlobalMapper\GlobalMapperSDK_vX" folder (where X is the version number of your copy of the SDK). For this example, open the sample_app folder, which contains a C++ implementation of an application called GMDLL_Tester.

  • Open GMDLL_Tester.sln with Visual Studio 2019 (v142)

  • Build and run the solution. Once it has finished building successfully, this interface window will open.

  • Click "Load New Layer...", and select a file and click "Open". Then, the layer(s) will be loaded into the workspace as seen in the image below.

  • From here, you can use the existing Global Mapper functionalities, or add new functionalities, or both. For example, after loading a layer, you might export it as a JPG, GeoTIFF, or KML Vector, and then click "Close layer(s)". All of the code for these operations is available in the sample_app folder, so that you can see how they were implemented into the application.

Loading a file is similar in the other sample apps as well. Sample_app_C#_managed is an example of an application written in C# that references GlobalMapperWrapperNET45.dll, a .net wrapper, and showcases the implementation of some of the uses of the SDK. Additonally, the other sample folders are sample_app_C#_WPF, sample_app_Delphi, and sample_app_VB, which demonstrate the use of SDK in C#, Pascal, and VB; sample_app_web_Managed, that shows the implementation of the SDK as a web app; and sample_tb_extension, sample_tb_extension_mfc, and sample_tb_extension_overview contain sample extensions for Global Mapper.

 

Example of Load and Display of a workspace

Prompt user to select a file and load the layers

Copy
GM_Error_t32
GM_MapWindow::LoadLayer
    (
    GM_LoadFlags_t32    aLoadFlags,
    LayerHandleList_t*  aLoadedLayersList,
    bool                aZoomToAllLayers
    )
{
    // Prompt the user to select a file
    char theFilename[_MAX_PATH];
    GM_Error_t32 theErr = GM_SelectFile( theFilename, NULL, NULL, mDrawWnd );

    // Load the layer
    if ( GM_Error_None == theErr )
    {
        theErr = LoadLayerImpl( theFilename, aLoadFlags, aLoadedLayersList, aZoomToAllLayers );
    }

    return ( theErr );
}

 

A portion of LoadLayerImpl that loads a layer list

Copy
// Load the layer
std::string theTableName="";
CString theExtraLoadFlags( theTableName.c_str() );
GM_LayerHandle_t32* theLayerHandleList = NULL;
uint32 theNumLayersLoaded = 0;
theErr = GM_LoadLayerListEx
(
    aFilename, &theLayerHandleList, &theNumLayersLoaded, aLoadFlags, theExtraLoadFlags
);

 

Fill Layer List

Copy
void 
CGMDLL_TesterDlg::FillLayerList() 
{
    // Add a column if we haven't done that yet
    if ( 0 == mLayerList.GetHeaderCtrl()->GetItemCount() )
    {
        mLayerList.InsertColumn( 0, "Description" );
    }

    // Clear the layer list
    mLayerList.DeleteAllItems();

    // Add an item for each layer
    const GM_MapWindow::LayerHandleList_t& theLayerHandleList = 
        mMapWindow.GetLayerList();
    for ( uint32 i = 0; i < theLayerHandleList.size(); i++ )
    {
        GM_LayerHandle_t32 theLayer = theLayerHandleList[i];

        // Get info about the layer
        const GM_LayerInfo_t* theLayerInfo = GM_GetLayerInfo( theLayer );
        if ( NULL == theLayerInfo )
        {
            ::AfxMessageBox( "Error getting layer info" );
            continue;
        }

        // Add the description to the list
        sint32 theIdx = mLayerList.InsertItem
            ( 
            mLayerList.GetItemCount(), theLayerInfo->mDescription 
            );
        mLayerList.SetItemData( theIdx, (DWORD_PTR)theLayer );
    }

    // Size the column to fill the list
    CRect theListRect;
    mLayerList.GetClientRect( theListRect );
    mLayerList.SetColumnWidth( 0, theListRect.Width() );
}