2013-10-23 58 views

回答

0

地圖的鏈接是一個PNG文件的直接鏈接,所以只需下載它並保存爲位圖文件即可。

void TestDlg1::OnButton1() 
{ 
    LPCTSTR pszMapUrl = 
     _T("http://maps.googleapis.com/maps/api/staticmap") 
     _T("?center=Brooklyn+Bridge,New+York,NY") 
     _T("&zoom=13&size=600x300&maptype=roadmap&markers=color") 
     _T(":blue|label:S|40.702147,-74.015794&markers=color:green|label") 
     _T(":G|40.711614,-74.&markers=color:red|color:red|label:") 
     _T("C|40.718217,-73.998284&sensor=false"); 

    LPCTSTR pszLocalfile = _T("c:\\Temp\\Map01.png"); 

    HRESULT hr = ::URLDownloadToFile(NULL, pszMapUrl, pszLocalfile, 0, NULL); 
    if (FAILED(hr))  AfxMessageBox(_T("Error in saving map !")); 
}