Search code examples
wpfxamlmapsbing

Bing maps WPF add location markers


I have a pushpin on my map, but when I click and drag the map the pushpin stays on the same spot on the screen and doesn't move with the map. How do I put the pushpin on a specific location (coordinates) and have it stay there? Here is my XAML code:

<Window x:Class="WPFKiosk.MapWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

         xmlns:m="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF"

        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WPFKiosk"
        mc:Ignorable="d"
        Title="MapWindow" Height="910" Width="1080" WindowStyle="None" ResizeMode="NoResize">

    <!-- -->
    <Grid Width="1080" Height="915">

       <!-- <Image HorizontalAlignment="Left" Height="644" Margin="20,64,-35,0" VerticalAlignment="Top" Width="1095" Source="Images/map.png"/> -->

        <m:Map x:Name="myMap" CredentialsProvider="My_Key" Mode="Road"/>
        <m:Pushpin Location="28,-81"
                   />
        <Image HorizontalAlignment="Left" Height="100" Margin="510,740,0,0" VerticalAlignment="Top" Width="100" Source="Images/iTO Back Arrow.png" MouseLeftButtonDown="Image_MouseLeftButtonDown"/>

    </Grid>
</Window>

Solution

  • The Pushpin is not "on the map".

    It should look like this:

    <m:Map x:Name="myMap" CredentialsProvider="My_Key" Mode="Road">
        <m:Pushpin Location="28,-81"/>
    </m:Map>