Code covered by the BSD License  

Highlights from
GoogleEarth in GUI

5.0

5.0 | 1 rating Rate this file 40 Downloads (last 30 days) File Size: 1.33 MB File ID: #32423
image thumbnail

GoogleEarth in GUI

by

 

03 Aug 2011 (Updated )

Open GE in Matlab - GUI via ActiveX

| Watch this File

File Information
Description

This function is an example on how to integrate GoogleEarth in a Matlab figure or GUI.
You need the GoogleEarth plugin to be installed. Therefore just visit a website, where the plugin is needed
and install it, e.g.: http://code.google.com/intl/de-DE/apis/earth/

Next step you'll need an api-key-see: http://code.google.com/intl/de-DE/apis/earth/documentation/index.html
Take the key and put it in the head of the ge_ma.html while replacing ABCDEF" -->
src="https://www.google.com/jsapi?key=ABCDEF"></script>
Maybe the abcdef-key also work - try it.

The rest is more simple:

The workaround for integrating GE in Matlab GUI is simple to embed a Microsoft Internet ActiveX-Control in the GUI (ge_html --> line 56); You need the activex: shell.explorer.2 (see Matlab Help)

Then you can import any website or a in our case a local html-document with your programmed GoogleEarth functionality (ge_ma.html). For further function-examples see the Google Code Playground:
http://code.google.com/apis/ajax/playground/?exp=earth#hello,_earth

At the Playground you can toogle to "Edit HTML" and save the code on local machine. The functions inside you can call from Matlab as shown in the pushbuttons of the GUI.

Further Readings:
  http://code.google.com/intl/de-DE/apis/earth/
  http://code.google.com/intl/de-DE/apis/earth/documentation/reference/index.html
see in Matlab Help: actx_explore for integrating Shell-Explorer

Programmed by Sven Koerner: koerner(underline)sven(add)gmx.de
Date: 2011/07/27

MATLAB release MATLAB 7.10 (R2010a)
Other requirements http://code.google.com/intl/de-DE/apis/earth/
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (22)
19 Feb 2014 Kehinde Adeniji

Hi all,am trying to load follow this example ,when i run the GUI am getting this error,

serialization of COM object failed.'Microsoft Web browser could not restored to its previous state.
make sure file mymap_activex1 is in the same directory as your GUI.

Thanks

13 Jul 2013 Pieter Mosterman

Make sure that you run Google Earth in a 32 bit version of MATLAB. Otherwise, Google Earth may fail to load.

01 Dec 2011 Sven Koerner

Hi Shewie,
when I'm right you have a couple of browsers installed: IE7, Chrome and IE9. First try this: open IE7 from windows (not in matlab) and check if GE-plugin is installed. If yes - it should work. Otherwise please deinstall IE7, so that the shell.explorer.2 only find IE9.

01 Dec 2011 Shewie Ferrari

Hi
when I open a Shell.Explorer.2, an InternetExplorer ver.7 is opened on a Matlab Figure... and that's ok... but I've tried so many times to install the GE Plugin... and with chrome/ie9 and other browser I'm able to see the Earth application (so the GEPlugin is correctly installed), but when I run the Matlab Code, it tell me that i need the Plugin!!!

08 Oct 2011 Mr Smart  
10 Sep 2011 Sven Koerner

Try one of this:
file://localhost/c|/abc.kml
file:///c|/abc.kml
file://localhost/c:/abc.kml

09 Sep 2011 tony

Thanks Sven,

Code doesn't work if I replace the url with ='c:\abc.kml'. Do you know what format should I use to let code know that I want to fetch KML file form local dirve?

05 Sep 2011 Sven Koerner

Hi tony, add this two functions to the html functions block. In the var url you can locate your kml-file.

//Function fetch the KML
function fetch(){
var url = 'http://sketchup.google.com/' +
'3dwarehouse/download?mid=28b27372e2016cca82bddec656c63017&rtyp=k2';
google.earth.fetchKml(ge, url, kmlFinishedLoading);
}

//Function finished loading
function kmlFinishedLoading(kmlObject) {
if (kmlObject) {
ge.getFeatures().appendChild(kmlObject);
}
}

In the matlab code you can insert a new button an run fetch in this example-gui like:

handles.myDoc.parentWindow.execScript('fetch()', 'Jscript');

For further readings: http://code.google.com/apis/ajax/playground/?exp=earth#fetch_good_kml

and

http://code.google.com/intl/de-DE/apis/earth/articles/earthapikml.html#fetchkml

When you ran that code you need to go the place: 37.77976, -122.418307 than press find

05 Sep 2011 Sven Koerner

Hi tony, add this two functions to the html functions block. In the var url you can locate your kml-file.

//Function fetch the KML
function fetch(){
var url = 'http://sketchup.google.com/' +
'3dwarehouse/download?mid=28b27372e2016cca82bddec656c63017&rtyp=k2';
google.earth.fetchKml(ge, url, kmlFinishedLoading);
}

//Function finished loading
function kmlFinishedLoading(kmlObject) {
if (kmlObject) {
ge.getFeatures().appendChild(kmlObject);
}
}

In the matlab code you can insert a new button an run fetch in this example-gui like:

handles.myDoc.parentWindow.execScript('fetch()', 'Jscript');

For further readings: http://code.google.com/apis/ajax/playground/?exp=earth#fetch_good_kml

and

http://code.google.com/intl/de-DE/apis/earth/articles/earthapikml.html#fetchkml

02 Sep 2011 tony

Hi Sven,

How to open a local kml file from this app? Say a abc.kml at c:\ root.

THanks.

17 Aug 2011 Javier

I have found the browser
'Microsoft Web Browser' 'Shell.Explorer.2' 'C:\Windows\System32\ieframe.dll'
But the example doesn't work properly because it doesn't show the figure only the axes, but the box below is showed...

17 Aug 2011 Sven Koerner

Hi Javier!
That sounds strange. When you run in matlabcommand: actxcontrollist
look at the ans and try to locate in the first row the Microsoft Web Browser (the 1. row is alphabetical order). When you find it - the component is registered. (If not try registering again with admin rights).
When the component is in the list, try to run the matlab example: http://www.mathworks.com/help/techdoc/matlab_external/bqdwu3j.html

Does this example run?

17 Aug 2011 Javier

Hi Sven!
I've tried to install the ieframe.dll regsvr32, but I get the error error 80004001 and when I execute your program it's showed a white window as I sent you by mail.

11 Aug 2011 Sven Koerner

in the commandwindow of windows

11 Aug 2011 Javier

I've tried the example but I get errors, the command do I have to use in commandwindow of windows or matlab prompt?

11 Aug 2011 Sven Koerner

To install do the following in commandwindow as admin:
regsvr32 ieframe.dll
The dll is located in C:\Windows\SysWOW64\ieframe.dll

You can test the ActiveX with the first Example on this site: http://www.mathworks.de/help/techdoc/matlab_external/bqdwu3j.html#bqdw216

11 Aug 2011 Javier

I use windows 7 64bits, and my browser is IExplorer9.
No I have got the same error, do you know how I can install the shell.explorer.2?

10 Aug 2011 Sven Koerner

Hi Javier,
which OS do you use? Which browser (version) do you have installed?
Do you already see the GE-picture?

10 Aug 2011 Javier

If I push the buttom "find", I get this error
??? Reference to non-existent field 'myDoc'.

Error in ==> ge_html>pushbutton8_Callback at 184
handles.myDoc.parentWindow.execScript(['findmyaddress(''',searchStr ,''')' ], 'Jscript');

Error in ==> gui_mainfcn at 96
feval(varargin{:});

Error in ==> ge_html at 42
gui_mainfcn(gui_State, varargin{:});

Error in ==> @(hObject,eventdata)ge_html('pushbutton8_Callback',hObject,eventdata,guidata(hObject))


??? Error while evaluating uicontrol Callback

04 Aug 2011 Sven Koerner

Update was sent. It will be online soon....

04 Aug 2011 Sven Koerner

Sorry, I forgot the fig file! I' ll update it.

04 Aug 2011 Javier

Thank you, I'm going to try it, but is a way to get a kye to work locally??
Without having the key I've proved the function ge2ma_demo and I got this error:

??? Error using ==> load
Unable to read file ge_html.fig: No such file or directory.

Error in ==> hgload>localLoadFile at 177
AllVars = load(filename, '-mat');

Error in ==> hgload at 59
[FigVersion, FigData, VerNum] = localLoadFile(filename);

Error in ==> openfig at 72
[fig, savedvisible] = hgload(filename, struct('Visible','off'));

Error in ==> gui_mainfcn>local_openfig at 286
gui_hFigure = openfig(name, singleton, visible);

Error in ==> gui_mainfcn at 159
gui_hFigure = local_openfig(gui_State.gui_Name, gui_SingletonOpt, gui_Visible);

Error in ==> ge_html at 42
gui_mainfcn(gui_State, varargin{:});

Error in ==> ge2ma_demo at 29
ge_html;

Updates
04 Aug 2011

added fig-File

Contact us