我目前正在开发一个应用程序,我需要在地图上显示位置图钉和地址,但是目前,当我放大或缩小时,图钉一直在移动,从外观上看,图钉也清晰可见从原来的经纬度移动。我的 XAML 模板如下
<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 代码
MapControl map = new MapControl(); 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);
有人可以建议我在这里做错了什么吗?我可以以某种方式改进它吗?要求是我需要显示位置地址和引脚。