我正在尝试使用BrowserControl和IGEPlugin在Windows Forms应用程序中获取鼠标的LAT / LON位置。
有人知道了吗?
最佳答案
如果您使用免费的Winforms Geplugin控件库librar,这并不太难-只需遵循以下简单步骤
您需要告诉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)
{
}
关于c# - 用于监听Google Earth COM API中的MouseEvent的样板代码,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3168258/