【问题标题】:Check if the user is moving the map in Bing Maps检查用户是否在 Bing 地图中移动地图
【发布时间】:2012-06-20 16:06:54
【问题描述】:

我正在尝试在 WPF 中使用 Bing 地图,但一切都令人困惑,因为在线搜索让我产生了错误的希望。我会搜索一些东西,但要获取 AJAX 版本而不是 WPF 版本。如果有人可以向我指出适当的文档或帮助解决这个问题,那么我将永远欠他们的债。

我的 WPF 应用程序中有一个地图,我想在用户滚动时对其进行跟踪。我尝试将地图绑定到 DragEnter 事件,但这并没有做任何事情。我的问题是,是否有一个事件可以用来检查用户是否正在平移或缩放地图?

提前致谢。

【问题讨论】:

  • 您想知道地图的中心是否在变化,ZoomLevel 是否在变化?还是您真的只需要知道用户是否在平移和滚动?

标签: wpf events bing-maps zooming panning


【解决方案1】:

事件ViewChangeOnFrame 似乎做你想做的事。
Handing Map Events

<m:Map ViewChangeOnFrame="MyMap_ViewChangeOnFrame" ...>

From MSDN

假设您定义了一个名为 CurrentPosition 的 TextBlock 元素 XAML 设计代码,可以跟踪地图视图的当前位置 当它在位置之间制作动画时。此代码跟踪 西北和东南方的经纬度位置 有界地图视图的角落。

void MyMap_ViewChangeOnFrame(object sender, MapEventArgs e)
{
    //Gets the map that raised this event
    Map map = (Map) sender;
    //Gets the bounded rectangle for the current frame
    LocationRect bounds = map.BoundingRectangle;
    //Update the current latitude and longitude
    CurrentPosition.Text += String.Format("Northwest: {0:F5}, Southeast: {1:F5} (Current)",
                bounds.Northwest, bounds.Southeast);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多