Google

www www.fairbytes.com
 
 
ARTICLES
 
 
 

Using Google Earth in VC++/ MFC Application
By    :
Ratheesh
Date :
18 - 01 - 2008
Desc : How to communicate with Google Earth from a MFC application

Using Google Earth in VC++/ MFC Application 

Lets see how to use or put it in other words - how to communicate with Google Earth from a MFC application . (In the coming tutorials we can check how to do this in Java).

Before starting
- Google Earth should be installed in your machine( This can be freely downloaded from Google Earth Download)
- VC++ 6.0 is required

We will develop a small dialog based application where user can enter values for Latitude, Longitude and Altitude. When the user clicks on a "Set Data" button it will start GE (Google Earth) with the given data set.

In MSDEV create a new Dialog based application named "GETest"
In the main dialog of the application provide three edit boxes. This is required for providing values for Latitude , Longitude  and Altitude.
In addition to the edit boxes add a button Labeled "Set Data" . 
Add a handler for this button.



In the GETestDlg.cpp add the following statement

#import "C:\Google\Google Earth\googleearth.exe" named_guids

(This is assuming that GE is installed directly in C drive. Please update the path to the actual location)
Modify the Set Data button handler code

void CGETestDlg::OnSetData()
{
/*  Make sure that all required data is entered in the edit boxes*/
//
// Declare a pointer for Main GE
application interface
HRESULT hr; EARTHLib::IApplicationGE* pGE;
//
//Create the instance .
//This will cause GE application
to start

hr = CoCreateInstance(EARTHLib::CLSID_ApplicationGE,

style="mso-tab-count: 1">            NULL, CLSCTX_LOCAL_SERVER,
            EARTHLib::IID_IApplicationGE,
            (void**) &pGE);
//
// Check the status
 if (hr != S_OK)
{
/* Handle Error
*/
}
 
//
// Next thing we want to acheive is setting the Lat, Long, Alt data.
// For this we should wait till GE is fully initialized.

while(!pGE->IsInitialized())
{
            Sleep(1000);
}
//
// Now GE is initialized .
// Set the Data
pGE->SetCameraParams(lat,long,alt,EARTHLib::RelativeToGroundAltitudeGE,0,0,0,2);
//
// Wait till GE sets the new data
while (pGE->GetStreamingProgressPercentage()<100)
{};
}

Thats it ! GE will now be displaying the data provided by you.
(Do not forget to call CoInitialize and CoUninitialize)


Let me know whether it was useful. Please give Feedback
In the coming tutorials we will see how to use GE in Java applications and also how to
use Virtual Earth.

 

Please donate if this article helped you .
This will help us to maintain the site

 
Comments
valium xanax bars order cheap 8]]] valium order europe =( buy accutane >:(( cialis for sale 1252 Phentermine mltli
buckstab
online auto insurance 111079 auto insurance :-DDD affordable car insurance 4575
buckstab
POST A COMMENT
( NEW USER? Click here to Register ) 

 

BACK

 
HOME | NEWS | CLASSIFIEDS | CONTESTS | ARTICLES | EMPLOYMENT EXCHANGE | FORUMS | BLOG | LINKS | DOWNLOAD
Contact Us | Privacy | Terms of Use