2012-02-29 17 views
3

GMap.Netコントロールのマルチタッチを有効にしようとしていますが、WPFビルドインイベントを使用していますが、成功しませんでした。GMapのズームとパン

thisthisのようなマルチタッチに関する記事があります。これらのすべてにおいて、ManipulationContainerはキャンバスで可動コントロールが置かれていますが、GMapの問題ManipulationContainerGMapControlであり、コントロールはありません。 e.ManipulationDeltaデータをズームして移動するにはどうすればよいですか?

GMapControlは、Zoomプロパティを持ちます。これを増減することで、ズームインまたはズームアウトできます。

答えて

3

コードを簡単に見ると、GMapControl is an ItemsContainerが表示されます。

あなたはそこIsManipulationEnabledプロパティItemsPanelテンプレートのスタイルを変更して供給することができる必要があります:

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

し、適切な方法を提供する:あなたはWindowを配線する必要がある。この時点で

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

をコードの背後にある(恥知らずに盗まれ、これから適応された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; 
} 
関連する問題