Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Calling Google Earth to display a UK Post Code

Posted on 2006-10-23
3
Medium Priority
?
491 Views
Last Modified: 2010-04-05
Is there a simple command line option to call Google Earth to display a UK Post Code (assuming that Google Earth is installed). If not, what is the easiest way to do this ?

Is there a way to test to see if Google Earth is installed

Are there any copyright issues or breaches in trying to do this?

Thanks.
0
Comment
Question by:WeeStinker
  • 3
3 Comments
 
LVL 28

Accepted Solution

by:
TName earned 2000 total points
ID: 17796765
Hi,
I've never done anything with GE, but you made me curious. While I don't know if you can pass a postal code as a parameter to GE, I tried to build a kml file with the post code and pass that as parameter. It works, kind of...
While the method works perfectly when you write coordinates into the kml file (GE opens and really goes to and zooms into the provided location), when only the post code is provided (It's supposed to work for the US, Canada and the UK), GE opens and displays the placemark, but only goes to that place if you double click the place mark. Now if you save the placemark as a kml file again, you will see that GE has added coordinates. If you make your code write those coordinates into the kml file that you pass to GE, everithing works fine.
I'm sure there are no copyright issues if you launch their program and make it go to a specific site :)

procedure TForm1.Button1Click(Sender: TObject);
var
s,FName,Zip:String;

begin
  FName:='C:\Test.kml';
  Zip:='SW1H 0BD';
  OpenGE(FName,Zip);
end;


function TForm1.OpenGE(FName,Zip:String):Boolean;
var
SL:TStringList;
begin
   SL:=TStringList.Create;
   SL.Add('<?xml version="1.0" encoding="UTF-8"?>');
   SL.Add('<kml xmlns="http://earth.google.com/kml/2.1">');
   SL.Add('<Document>');
   SL.Add('<Placemark>');
   SL.Add('<open>1</open>');
   SL.Add('<name>Test</name>');
   SL.Add('<description>A Zip Test</description>');
   SL.Add('<address>'+Zip+'</address>');
   //SL.Add('<Point>');
   //SL.Add('<coordinates>-0.134256,51.499365,0</coordinates>');
   //SL.Add('</Point>');
   SL.Add('</Placemark>');
   SL.Add('</Document>');
   SL.Add('</kml>');
   SL.SaveToFile(FName);
   ShellExecute(Handle,PChar('open'), PChar('C:\Program Files\Google\Google Earth\GoogleEarth.exe'), PChar(FName), nil, SW_SHOW);
end;
0
 
LVL 28

Expert Comment

by:TName
ID: 17797115
>Is there a way to test to see if Google Earth is installed

Have a look at ginsonic's post in this thread:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20263911.html
It loads a list of all installed programs in a listbox (could be changed to use a stringlist)
Then you can loop through the listbox and see if GE is installed, e.g:

for i:=0 to ListBox1.Items.Count-1 do begin
     if Trim(ListBox1.Items[i])='Google Earth' then
       ShowMessage('Yes');
0
 
LVL 28

Expert Comment

by:TName
ID: 17797459
>>Are there any copyright issues or breaches in trying to do this?
>I'm sure there are no copyright issues if you launch their program and make it go to a specific site :)

It just occured to me that you might mean copyright issues regarding the postal codes. No idea about that, maybe someone from the UK can help.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Integration Management Part 2
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question