| Launch in external player |
What will you find here?
- You will find here the binary for Windows and the source code in C++ of a program that allows Google Earth to track the GPS location of one or more elements in real time.
- The program only works with GPS that use the NMEA protocol.
- The purpose of this page is to give a starting point to programmers interested in building applications capable of interacting with Google Earth.
- What the small and ready to use console program does is to read NMEA data from a GPS attached to a COM port, then generates KML data defining a Placemark at the corresponding latitude and longitude and finally publishes it over http so Google Earth can locally or remotely retrieve it using a Network Link.
How can this program be used?
- The most simple use is for tracking your position from a laptop if you have an internet connection or Google Earth data in cache.
- A more advanced used, which is why this program was written, was the tracking of multiple mobile robots in real time.
- More generally, having the C++ source code of a http server publishing KML data is a good starting point for anybody wanting a custom program make Google Earth automatically load data.
How to start the program?
- This is a console program, so this means you will have to start it from the MS-DOS command prompt.
- Click on the "Start" menu (at the lower left of your screen) and select "Run...".
- If you are using Windows XP, then type "cmd" (no quotation marks) into the box and click "OK"; otherwise, type "command" (no quotation marks) into the box and click "OK".
- You should see an MS-DOS Command Prompt window appear.
- Now you have to go to the folder where the program is located by using the following commands:
- Type "dir" (no quotation marks) to see the content of the directory you are in.
- To go to a "child" directory type "cd name_of_directory" (no quotation marks) .
- To go to the parent directory type "cd.." (no quotation marks) .
- Once you are in the directory where the program is located, start the program by typing the following: gpsserver http_port com_port label
- "gpsserver" is the name of the program.
- "http_port" is the port of the server where the KML data will be published.
- "com_port" is the COM port where the GPS is connected.
- "label" is the name we want to give to the Placemark in Google Earth.
- Example: "gpsserver 81 4 me" this will retrieve the NMEA data of a GPS connected to COM port 4 and publish KML data on http port 81 so Google Earth shows at the GPS location a Placemark labeled as "me".
- Enter "CTRL+C" to exit the program.
- Go to the top menu and select "Add" and "Network Link..."
- As a "Link" enter "http://computer_ip:http_port" where "computer_ip" is the IP of a distant machine where the program is running and "http_port" is the port parameter we introduced in the command prompt when starting the program. (If the server is running on the same machine as Google Earth you can use "localhost" instead of the computer IP). "
- Then select the "Refresh" tab and set "When" to "Periodically" and to 1 second.
- Press "OK".
- The C++ source code for the http server was found some place on the internet, I just modified it for the application and built a project for Visual Studio 2005.
- If you don't like the icon used by the program for the Placemark, to change it is simply a matter of saving as KML a Placemark of your taste from Google Earth and to replace with it the definition of the marker that you will find in "main.cpp". Another interesting posibility is to use and update periodically an image overlay instead of using a marker.
- The procedure above works for any kind of Google Earth object as long as it is KML, in the code in "main.cpp" just replace "message_to_GE" with the appropriate KML data, the possibilities are therefore unlimited.