Solved

Calling Google Earth to display a UK Post Code

Posted on 2006-10-23
3
481 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 500 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Comparing dates in Delphi. Greater than/ Less than 3 225
Press three keys together and trigger a function 3 62
Dev express lookupcombo 3 35
DBCtrlGrid, Delphi, Scroll 7 26
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

821 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