用于在 Google Earth COM API 中侦听 MouseEvents 的样板代码

发布于 2024-09-07 20:24:42 字数 84 浏览 4 评论 0原文

我正在尝试使用 browsercontrol 和 IGEPlugin 在 Windows 窗体应用程序中获取鼠标的 LAT/LON 位置。 有人有线索吗?

I'm trying to get the LAT/LON position of the mouse in a Windows Forms app using the browsercontrol and IGEPlugin.
Anyone got a clue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青丝拂面 2024-09-14 20:24:42

如果您使用免费的 Winforms Geplugin 控件库,这并不是太难 - 只需遵循以下简单步骤

您需要告诉 Web 浏览器对象您想要侦听 mousemove 事件

 geWebBrowser.AddEventListener(gePlugin.getGlobe(), "mousemove");

然后您需要设置一些事件处理程序。下面的代码应该很容易阅读。您可以从 DoMouseMove 方法中的 mouseEvent 参数确定鼠标光标的纬度/经度

geWebBrowser.KmlEvent += GeWebBrowserKmlEvent;


private void GeWebBrowserKmlEvent(object sender, GEEventArgs e)
        {
            // if it is a mouse event
            if (null != sender as IKmlMouseEvent)
            {
                handleKmlMouseEvents((IKmlMouseEvent)sender, e.Data);
            }
            else
            {
                MessageBox.Show(GEHelpers.GetTypeFromRcw(sender));
            }
        }

 private void handleKmlMouseEvents(IKmlMouseEvent mouseEvent, string action)
        {
            string currentTarget = mouseEvent.getCurrentTarget().getType();

            switch (action)
            {
                case "mousemove":
                    {
                        DoMouseMove(mouseEvent);
                        break;
                    }

                case "click":
                    {
                        DoClick(mouseEvent, currentTarget);
                        break;
                    }
                case "mousedown":
                    {
                        DoMouseDown(mouseEvent, currentTarget);
                        break;
                    }
                case "mouseup":
                    {
                        DoMouseUp(mouseEvent);
                        break;
                    }
            }
        }

 private void DoMouseMove(IKmlMouseEvent mouseEvent)
 {

 }

This isn't too hard if you use the free Winforms Geplugin control librar y- just follow these simple steps

You need to tell the web browser object that you want to listen for mousemove events

 geWebBrowser.AddEventListener(gePlugin.getGlobe(), "mousemove");

Then you need setup some event handlers. The code below should be easy to read. You can determine the lat / long of the mouse cursor from the mouseEvent argument in the DoMouseMove method

geWebBrowser.KmlEvent += GeWebBrowserKmlEvent;


private void GeWebBrowserKmlEvent(object sender, GEEventArgs e)
        {
            // if it is a mouse event
            if (null != sender as IKmlMouseEvent)
            {
                handleKmlMouseEvents((IKmlMouseEvent)sender, e.Data);
            }
            else
            {
                MessageBox.Show(GEHelpers.GetTypeFromRcw(sender));
            }
        }

 private void handleKmlMouseEvents(IKmlMouseEvent mouseEvent, string action)
        {
            string currentTarget = mouseEvent.getCurrentTarget().getType();

            switch (action)
            {
                case "mousemove":
                    {
                        DoMouseMove(mouseEvent);
                        break;
                    }

                case "click":
                    {
                        DoClick(mouseEvent, currentTarget);
                        break;
                    }
                case "mousedown":
                    {
                        DoMouseDown(mouseEvent, currentTarget);
                        break;
                    }
                case "mouseup":
                    {
                        DoMouseUp(mouseEvent);
                        break;
                    }
            }
        }

 private void DoMouseMove(IKmlMouseEvent mouseEvent)
 {

 }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文