在GMap.net中缩放和平移

我正在尝试使用WPF内置事件启用GMap.Net控件多点触控,但我没有成功。

我发现了一系列关于多点触控的文章,就像这个和这个一样。 在所有这些中, ManipulationContainer是一个canvas和可移动控件放在它上面,但在GMap问题中, ManipulationContainerGMapControl并且无法控制它。 我如何使用e.ManipulationDelta数据进行缩放和移动?

GMapControl具有Zoom属性,通过增加或减少它,您可以放大或缩小。

快速查看代码显示GMapControlItemsContainer

您应该能够重新设置ItemsPanel模板并在那里提供IsManipulationEnabled属性:

        

此时你需要连接Window

  

并在Code Behind中提供适当的方法(无耻地窃取并改编自此MSDN演练 ):

 void Window_ManipulationStarting( object sender, ManipulationStartingEventArgs e) { e.ManipulationContainer = this; e.Handled = true; } void Window_ManipulationDelta(object sender, ManipulationDeltaEventArgs e) { // uses the scaling value to supply the Zoom amount this.Map.Zoom = e.DeltaManipulation.Scale.X; e.Handled = true; } void Window_InertiaStarting( object sender, ManipulationInertiaStartingEventArgs e) { // Decrease the velocity of the Rectangle's resizing by // 0.1 inches per second every second. // (0.1 inches * 96 pixels per inch / (1000ms^2) e.ExpansionBehavior.DesiredDeceleration = 0.1 * 96 / (1000.0 * 1000.0); e.Handled = true; }