1
votes

I'm having trouble finding a way to add a pushpin to a MapControl app in a Windows Phone 8.1 app.

For the previous Map control, I see instructions here, http://msdn.microsoft.com/en-us/library/hh709044.aspx.

But not for Windows Phone "WinRT" apps.

Ideas appreciated. Thanks.

1

1 Answers

3
votes

You can add a pushpin using the MapElements property of the map.

// ensure you set the location of the pin ;)
Map.MapElements.Add(new MapIcon());

You can bind a collection of places using the MapItemsControl. You can place any xaml in the ItemTemplate of the control.

<maps:MapControl x:Name="Map" MapServiceToken="abcdef-abcdefghijklmno">
    <maps:MapItemsControl ItemsSource="{Binding Locations}">
        <maps:MapItemsControl.ItemTemplate>
            <DataTemplate>
                <Image Source="Assets/Mappin.png" Height="25"
                        maps:MapControl.NormalizedAnchorPoint="1,0.5" 
                        maps:MapControl.Location="{Binding Geopoint}" />
            </DataTemplate>
        </maps:MapItemsControl.ItemTemplate>
    </maps:MapItemsControl>
</maps:MapControl>

Hope that helps.