Micah
Micah

Reputation: 49

How to Set a MapStyle for the MapControl in Windows Phone 8.1

I'd like to update my Windows Phone 8.1 app to have the map load in the Aerial style. I have found documentation but how to complete this task still isn't apparent to me. In searching high and low, I've been unable to find a working example. Can someone explain how to set Style/MapStyle here if I simply want to use the Aerial style?

<bm:MapControl MapServiceToken="BLANK" x:Name="myMap" Height="560" Margin="0,0,0,0" Style="" />

Documentation: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn642089.aspx

Upvotes: 0

Views: 544

Answers (4)

n4rs
n4rs

Reputation: 11

This worked for me:

MainPage.xaml.cs

public MainPage()
{
      this.InitializeComponent();
      MyMap.Style = MapStyle.AerialWithRoads;
}

Upvotes: 0

Luke Xavier Sewell
Luke Xavier Sewell

Reputation: 11

I got mine to work by setting it in code.

myMap.Style = MapStyle.AerialWithRoads;
or
myMap.Style = MapStyle.Aerial;

Upvotes: 1

stambikk
stambikk

Reputation: 1365

When you try to set the Style property in XAML it shows this error:The TypeConverter for "Style" does not support converting from a string. So you have two options:

  1. Set it in code behind like in your own answer
  2. Bind it to a property in your Viewmodel like this: Style="{Binding MapStyle}"

Upvotes: 0

Micah
Micah

Reputation: 49

I wound up figuring this problem out on my own by looking at deprecated examples and fiddling around with the code-behind. I hope that this helps someone else!

Private Sub Page_Load(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
    myMap.Style = Maps.MapStyle.Aerial
End Sub

Upvotes: 0

Related Questions