Ariel
Ariel

Reputation: 5830

How to add pushpin to Windows Phone 8.1 MapControl

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.

Upvotes: 1

Views: 3811

Answers (1)

Shawn Kendrot
Shawn Kendrot

Reputation: 12465

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.

Upvotes: 3

Related Questions