I am currently working on an app where I need to show location pins along with address on the map, but currently, when I zoom in or zoom out, the pin keeps moving and from the look and feel, it's clearly visible that pin is also moving from its original lat-long. My XAML template is as following
<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 code
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);
Can someone suggest what I am doing wrong here? Can I improve it in some way? The requirement is such that I need to show location address along with pin.