在CBuilder下呼叫google earth api函式openkmlfile沒有效果,但呼叫其它幾個函式作業正常,有誰碰到過這種情況嗎?怎樣解決的?
代碼如下:
TApplicationGE *ApplicationGE1;
......
::CoInitialize(NULL);
ApplicationGE1->IsInitialized();
m_hMain = (HWND) ApplicationGE1->GetMainHwnd();
m_hView = (HWND) ApplicationGE1->GetRenderHwnd();
ShowWindow((HWND)m_hMain, SW_HIDE);
::SetParent((HWND)m_hView,Form1->Panel1->Handle);
::SetWindowPos((HWND)m_hView,HWND_TOPMOST,100,400,200,100,SWP_SHOWWINDOW);
::MoveWindow(m_hView, 0, 0, Form1->Panel1->Width, Form1->Panel1->Height, true);
......
ApplicationGE1->SetCameraParams(108.65,34.5,500,1,4000,0,0,20); // 正常
ApplicationGE1->OpenKmlFile((wchar_t *)"c:\\a.kml",1); // 沒反應
誰能給下解決方案,不勝感激!
uj5u.com熱心網友回復:
雖不曾用過Google Earth API,但是從COM這塊考慮,這行代碼:ApplicationGE1->OpenKmlFile((wchar_t *)"c:\\a.kml",1);
改成:
ApplicationGE1->OpenKmlFile(WideString("c:\\a.kml"), 1);
你試試吧。
uj5u.com熱心網友回復:
char szPath[MAX_PATH];memset(szPath,0,MAX_PATH);
GetCurrentDirectory(MAX_PATH,szPath);
strcat(szPath,"\\我的地點.kmz");
CString path(szPath);
g_IApplicationGE.OpenKmlFile(path,TRUE);
(其中,g_IApplicationGE是:g_IApplicationGE.CreateDispatch(CLSID_ApplicationGE);//系結g_IApplicationGE和GE程式)
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/124441.html
