The Maps control can be viewed using one of the following four cartographic modes (represented by the MapCartographicMode
enum):
Aerial
Hybrid
Road
Terrain
A cartographic mode represents a 2D projection of the Earth. You set the cartographic mode of a Map
using its CartographicMode
property.
The sample’s MapViewModel
class contains a MapCartographicModes
property, which is an IEnumerable<MapCartographicMode>
. The backing field for the property is populated using the custom EnumUtility
class, which extracts each enum value and provides the viewmodel with an IEnumerable
that is compatible with data-binding.
readonly IEnumerable<MapCartographicMode> mapCartographicModes
= EnumUtility.CreateEnumValueList<MapCartographicMode>();
The MapView
page uses a Windows Phone Toolkit ListPicker
control, which is bound to the MapCartographicModes
property, allowing the user to switch between modes. See the following excerpt:
<toolkit:ListPicker
ItemsSource="{Binding MapCartographicModes}"
SelectedItem="{Binding MapCartographicMode, Mode=TwoWay}"
ExpansionMode="FullScreenOnly"
The SelectedItem
property of the ListPicker
is bound to the viewmodel’s MapCartographicMode
property. The Map control’s CartographicMode
property is also bound to the viewmodel’s MapCartographicMode
property, as shown:
<m:Map x:Name="map"
...
CartographicMode="{Binding MapCartographicMode, Mode=TwoWay}"
...
>
</m:Map>
Changing the mode via the list picker causes the map to change modes.
3.145.70.170