2011-08-09 8 views
2

Bingマップコントロールを使用すると、位置マーカーを楕円として描画するオーバーレイが追加されます。各楕円は、WP7エミュレータで期待どおりに動作するタップハンドラに配線されています。悲しいことに、これはHTCハードウェアの場合とは違います - 地図自体はすべての入力を受け取りそうです。誰もが私はこれを修正する方法を知っています。インタラクティブレイヤーを使った実例がありますか?Silverlight 4およびWindows Phone 7用のBingマップコントロールのインタラクティブレイヤー

Thxを++

+0

が満たされた楕円はありますか? –

答えて

4

あなたは、Visual Studio 2010でデフォルトのテンプレートを使用して新しいのWindows Phone 7.1 Silverlightアプリケーションを作成する場合は、単にMainPage.xamlをしてMainPage.csファイルに次のようにコピーします。 System.DeviceとMicrosoft.Phone.Controls.MapsのDLLも参照する必要があります。これにより、省略記号をクリックする必要があります。私は2つの異なるWP7の携帯電話でそれをテストし、それは正常に動作します。

XAML

<phone:PhoneApplicationPage 
    x:Class="SampleMapApp.MainPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" 
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:maps="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps" 
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768" 
    FontFamily="{StaticResource PhoneFontFamilyNormal}" 
    FontSize="{StaticResource PhoneFontSizeNormal}" 
    Foreground="{StaticResource PhoneForegroundBrush}" 
    SupportedOrientations="Portrait" Orientation="Portrait" 
    shell:SystemTray.IsVisible="True"> 

    <phone:PhoneApplicationPage.Resources> 
     <DataTemplate x:Name="EllipseTemplate"> 
      <maps:Pushpin Location="{Binding}" Tap="Pushpin_Tap"> 
       <maps:Pushpin.Template> 
        <ControlTemplate> 
         <Ellipse Width="15" Height="15" Stroke="White" StrokeThickness="2"> 
          <Ellipse.RenderTransform> 
           <TranslateTransform X="-5" Y="5"/> 
          </Ellipse.RenderTransform> 
          <Ellipse.Fill> 
           <SolidColorBrush Color="DarkBlue" Opacity="0.8"/> 
          </Ellipse.Fill> 
         </Ellipse> 
        </ControlTemplate> 
       </maps:Pushpin.Template> 
      </maps:Pushpin> 
     </DataTemplate> 
    </phone:PhoneApplicationPage.Resources> 

    <!--LayoutRoot is the root grid where all page content is placed--> 
    <Grid x:Name="LayoutRoot" Background="Transparent"> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="Auto"/> 
      <RowDefinition Height="*"/> 
     </Grid.RowDefinitions> 
     <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="5"> 
      <TextBlock Text="Sample Map Application" Style="{StaticResource PhoneTextNormalStyle}"/> 
     </StackPanel> 

     <Grid x:Name="ContentPanel" Grid.Row="1" Margin="0"> 
      <maps:Map> 
       <maps:MapLayer> 
        <maps:MapItemsControl ItemsSource="{Binding Locations}" ItemTemplate="{StaticResource EllipseTemplate}"/> 
       </maps:MapLayer> 
       <maps:Pushpin Location="{Binding CurrentLocation, Mode=TwoWay}" Content="{Binding CurrentLocation, Mode=TwoWay}"/> 
      </maps:Map> 
     </Grid> 
    </Grid> 

</phone:PhoneApplicationPage> 

CS

using System.Collections.ObjectModel; 
using System.Device.Location; 
using System.Windows; 
using System.Windows.Input; 
using Microsoft.Phone.Controls; 
using Microsoft.Phone.Controls.Maps; 

namespace SampleMapApp { 
    public partial class MainPage : PhoneApplicationPage { 
     // Constructor 
     public MainPage() { 
      InitializeComponent(); 
      Locations = new ObservableCollection<GeoCoordinate>() { 
       new GeoCoordinate(-56, 73), 
       new GeoCoordinate(-14, 120), 
       new GeoCoordinate(48, -133), 
       new GeoCoordinate(-2, 11), 
       new GeoCoordinate(0, 40), 
       new GeoCoordinate(-78, -85), 
      }; 
      CurrentLocation = Locations[0]; 
      DataContext = this; 
     } 

     public ObservableCollection<GeoCoordinate> Locations { get; set; } 

     #region CurrentLocation 
     public GeoCoordinate CurrentLocation { 
      get { return (GeoCoordinate) GetValue(CurrentLocationProperty); } 
      set { SetValue(CurrentLocationProperty, value); } 
     } 

     public static readonly DependencyProperty CurrentLocationProperty = 
      DependencyProperty.Register("CurrentLocation", typeof(GeoCoordinate), typeof(MainPage), new PropertyMetadata(null)); 
     #endregion 

     private void Pushpin_Tap(object sender, GestureEventArgs e) { 
      CurrentLocation = (sender as Pushpin).Location; 
     } 
    } 
} 
+0

ニース、詳細な応答に感謝します。 –

関連する問題