VC++ MapWinGis篇(创建图层)

青春壹個敷衍的年華 提交于 2020-01-25 17:06:10

MapWinGis控件的引用:

#import "MapWinGIS.ocx" rename("IImage","gisIImage") rename("ImageType", "gisImageType") rename("Point", "gisPoint")
using namespace MapWinGIS;

创建新图层m_pShapefilePoint,并添加图层属性: 

    MapWinGIS::IShapefilePtr m_pShapefilePoint;
    m_pShapefilePoint.CreateInstance(__uuidof(MapWinGIS::Shapefile));
    if (!m_pShapefilePoint->Open("./maps/GpsPoints.shp", NULL))
    {
        CString sError = m_pShapefilePoint->GetErrorMsg(m_pShapefilePoint->GetLastErrorCode());
        TRACE(sError);

        if (!m_pShapefilePoint->CreateNew("./maps/GpsPoints.shp", /*MapWinGIS::ShpfileType::*/SHP_POINT))
        {
            sError.Format("%s", m_pShapefilePoint->GetErrorMsg(m_pShapefilePoint->GetLastErrorCode()));
            TRACE(sError);
            return ;
        }

        m_pShapefilePoint->StartEditingTable(NULL);
        long lFieldIndex = 0;
        lFieldIndex = m_pShapefilePoint->EditAddField(_bstr_t("name"), STRING_FIELD, 0, 64);// 添加的属性
        lFieldIndex = m_pShapefilePoint->EditAddField(_bstr_t("type"), INTEGER_FIELD, 0, sizeof(int));//添加的属性
        m_pShapefilePoint->StopEditingTable(TRUE, NULL);
    }

    m_pShapefilePoint->put_CollisionMode(AllowCollisions);

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!