Skip to content

Latest commit

 

History

History
55 lines (42 loc) · 1.59 KB

mapcontrol_stylesheet.md

File metadata and controls

55 lines (42 loc) · 1.59 KB
-api-id -api-type
P:Windows.UI.Xaml.Controls.Maps.MapControl.StyleSheet
winrt property

Windows.UI.Xaml.Controls.Maps.MapControl.StyleSheet

-description

Gets or sets an object that defines the style of the map control.

-property-value

An object that defines the style of the map control.

-remarks

-see-also

-examples

The following example sets the StyleSheet property by using one of the provided styles through the static MapStyleSheet.RoadDark method.

  myMap.StyleSheet = MapStyleSheet.RoadDark();

Custom map styles can be defined in JSON and loaded through the MapStyleSheet.ParseFromJson method. They can optionally combined with a provided style.

A scalable way to do this is to create a file named MyStyle.json in the Assets folder of a UWP application. Make sure that its Build Action property is set to Content.

{
    "version": "1.*",
    "elements":{
        "water":{
            "fillColor":"#FF000000"
        }
    }
}

Add the following code to the application which has a MapControl named myMap.

Uri uri = new Uri("ms-appx:///Assets/MyStyle.json");
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(uri);
string jsonText = await FileIO.ReadTextAsync(file);
myMap.StyleSheet = MapStyleSheet.Combine(new List<MapStyleSheet>
{
    MapStyleSheet.RoadLight(),
    MapStyleSheet.ParseFromJson(jsonText)
});