缩放和平移在GMap.net [英] Zoom and Pan in GMap.net

查看:2115
本文介绍了缩放和平移在GMap.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让 GMap.Net 控制多点触控启用,使用WPF内置的事件,但我没有成功。

I'm trying to make GMap.Net control multitouch enabled, using WPF build-in events but i wasn't successful.

我发现了一系列关于类似的这个并的此内容之一。在所有这些, ManipulationContainer 是一个帆布和放置其上可移动的控制,但在GMAP问题 ManipulationContainer GMapControl 并没有在它的控制。如何使用 e.ManipulationDelta 数据进行缩放和移动?

I found a series of articles about multitouch like this and this one. In all of them, ManipulationContainer is a canvas and movable controls placed on it, but in GMap issue ManipulationContainer is GMapControl and there is no control over it. how can i use e.ManipulationDelta data to Zoom and Move?

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

The GMapControl has a Zoom property which by increase or decreasing it, you can zoom in or zoom out.

推荐答案

一个快速浏览一下代码表明的 GMapControl ItemsContainer

A quick look at the code shows that the GMapControl is an ItemsContainer.

您应该能够restyle的 ItemsPanel 模板,并提供 IsManipulationEnabled 属性有:

You should be able to restyle the ItemsPanel template and supply the IsManipulationEnabled property there:

<g:GMapControl x:Name="Map" ...>
   <g:GMapControl.ItemsPanel>
       <ItemsPanelTemplate>
           <Canvas IsManipulationEnabled="True" />
       </ItemsPanelTemplate>
   </g:GMapControl.ItemsPanel>
   <!-- ... -->



在这一点上,你需要接线了窗口

<Window ...
    ManipulationStarting="Window_ManipulationStarting"
    ManipulationDelta="Window_ManipulationDelta"
    ManipulationInertiaStarting="Window_InertiaStarting">

和提供在代码中的适当方法的背后(无耻地窃取,并从该的 MSDN演练):

And supply the appropriate methods in the Code Behind (shamelessly stolen and adapted from this MSDN Walkthrough):

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;
}

这篇关于缩放和平移在GMap.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆