2017-06-12 39 views
0

我目前正在开发一个应用程序,我需要在地图上显示地址引脚以及地址,但目前当我放大或缩小时,销子不断移动,从外观和感觉上,它清晰可见,销子也从原来的拉长。我的XAML模板是如以下定位销在地图放大或UWP缩小时位于地图项目控制下移动

<DataTemplate x:Key="MapItemTemplate"> 
     <StackPanel Orientation="Vertical" 
       x:Name="pushPin" 
       DataContext="{Binding}" 
       Tapped="pushPin_Tapped"> 
      <Border BorderThickness="1" BorderBrush="LightGray"> 
       <StackPanel x:Name="MapIcon" 
         Background="White" > 
        <TextBlock Text="{Binding LocationAddress}" 
           Foreground="Black" 
           FontWeight="SemiBold" 
           FontSize="12" 
           Margin="5" 
           TextWrapping="WrapWholeWords"/> 
       </StackPanel> 
      </Border> 
      <Image Height="30" 
        VerticalAlignment="Top" 
        maps:MapControl.Location="{Binding LocationGeoCoordinate}" 
        maps:MapControl.NormalizedAnchorPoint="0.5,0.5" 
        Source="ms-appx:///Images/pushpin.png"/> 

     </StackPanel> 
    </DataTemplate> 

的.cs代码

地图控件地图=新地图控件(); map.MapServiceToken =“MyMapServiceToken”;

  MapItemsControl itemsMapControl = new MapItemsControl(); 
      itemsMapControl.ItemTemplate = this.Resources["MapItemTemplate"] as DataTemplate; 

      map.Children.Add(itemsMapControl); 
      Grid.SetRow(map, 1); 

      mapViewGrid.Children.Add(map); 
      var stdMapItemControl = children.FirstOrDefault(x => x.GetType() == typeof(MapItemsControl)) as MapItemsControl; 
      itemsMapControl.ItemsSource = locationsList; 
      await map.TrySetViewAsync(locationsList[0].LocationGeoCoordinate, 15D, 0, 0, MapAnimationKind.Bow); 

有人可以建议我在做什么错吗?我能以某种方式改进它吗?要求是这样的,我需要显示位置地址以及引脚。

回答

相关问题