void CmapwingisTest2View::OnToolsAddLayer()
{
TCHAR szFilters[]= _T("TIFF Files (*.tif)|*.tif|SHP Files (*.shp)|*.shp||");
CFileDialog fileDlg (TRUE,_T("tif"),_T("*.tif"),
OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, szFilters, this);
if( fileDlg.DoModal ()!=IDOK ) return;
CString m_strFilePath = fileDlg.GetPathName();
if (_T("")!=m_strFilePath)
{
// delete all layers
//m_map.RemoveAllLayers();
// Get the extension to determine the file is an image or tif file shp
CString strExt = m_strFilePath.Right(3);
if (_T("tif")==strExt)
{
// create an image interface to open the image to the map
mapWindow::IImagePtr pImage;
pImage.CreateInstance(__uuidof(mapWindow::Image));
pImage->Open(_bstr_t(m_strFilePath),mapWindow::USE_FILE_EXTENSION,TRUE,NULL);
m_map.AddLayer(pImage,true);
}
if (_T("shp")==strExt)
{
mapWindow::IShapefilePtr pshapefilebound;
pshapefilebound.CreateInstance(__uuidof(mapWindow::Shapefile));
pshapefilebound->Open(_bstr_t(m_strFilePath),false );
m_map.AddLayer( pshapefilebound,TRUE) ;
return;
}
}
return;
}