开发者

capturing a click event on Google Earth plugin

Using the Goog开发者_运维问答le Earth Plugin in C#, I want to get clicked position on the earth; how can I do this?

using GEPlugin;

m_ge = (IGEPlugin)pluginInstance;
KmlLookAtCoClass lookAt =  m_ge.createLookAt("");
lookAt.set(35.337919, 33.321576, 0, m_ge.ALTITUDE_RELATIVE_TO_GROUND, 0, 0, 5000);

m_ge.getView().setAbstractView(lookAt);

m_ge.getLayerRoot().enableLayerById(m_ge.LAYER_ROADS, 1);

Now I want to add Click Event listener that I want to get click event.

How can this be done?


EDIT

The GEWebBrowser inherits from the standard System.Windows.Forms.WebBrowser control class and has the same base members, methods, properties and events.

Because of this, you'll need to manually create bi-directional communication between this control and your C# class.

See this article for how to wire up C# to javascript events in a browser control. http://support.microsoft.com/kb/312777

Also, you may find the following C# method useful for adding javascript events to the GEWebBrowser.

Void AddEventListener(object, string, string)

Wrapper for the the google.earth.addEventListener method

Parameters

object: The target plug-in Api object

string: The event Id

string: The name of javascript callback function to use

example: GEWebBrowser.AddEventListener(object,"click","function(event){alert(event.getType());}");

src: http://code.google.com/p/winforms-geplugin-control-library/wiki/GEWebBrowser


Not entirely sure, but perhaps one of these links will help you out.

http://fraserchapman.blogspot.com/2008/08/google-earth-plug-in-and-c.html

http://groups.google.com/group/google-earth-browser-plugin/browse_thread/thread/90dfb80960094828?pli=1

http://interactiveearth.blogspot.com/2008/01/create-your-own-google-earth.html

http://www.xtremevbtalk.com/showthread.php?t=287038


The problem is that the standard event handlers are part of the google.earth namespace and are not directly accessible via managed code. You need to 'relay' the events to your application via javascript and a COM visible class.

I have developed a free control library that allows you to easily embed the google earth plugin into an application.

It supports the AddEventListner and RemoveEventListner functions that you are looking for http://code.google.com/p/winforms-geplugin-control-library/wiki/AddEventListener

It is worth noting that it does not use, as in your example, the GEPlugin Type Library - rather the dynamic type in C#4.0. This means that it is not 'version dependent' on a particular version of the Google Earth Plugin

The main project is here http://code.google.com/p/winforms-geplugin-control-library/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜