MapWinGIS:SampleCode-C++ Builder 6
From MapWindow GIS
Para agregar una capa (layer) en un mapa (TMap) en C++ Builder 6.0, después de varios intentos pude hacerlo con el siguiente código:
Ojo, No utilizarlo cuando se crea el formulario principal (función FormCreate).
//---------------------------------------------------------------------------
void __fastcall TForm1::ToolButton1Click(TObject *Sender)
{
IShapefilePtr shapefile1;
shapefile1.CreateInstance(CLSID_Shapefile);
/* this is the alternatif if using OpenFileDialog
IShapefilePtr shapefile1;
WideString filename;
if (OpenVector->Execute())
{
shapefile1.CreateInstance(CLSID_Shapefile);
filename = OpenVector->FileName;
shapefile1->Open(filename.c_bstr(), NULL );
Map->AddLayer(shapefile1,true);
}
*/
BSTR filename=SysAllocString(L"C:\\Documents and Settings\\Administrador\\Mis documentos\\SharpDevelop Projects\\GISSampleApplication01\\GISSampleData\\Nile.shp");
shapefile1->Open(filename, NULL );
Map1->AddLayer(shapefile1,true);
}
//---------------------------------------------------------------------------
