MapStyleSheet MapStyleSheet MapStyleSheet Class

Definition

Represents a set of rules that define the style of a map control.

public sealed class MapStyleSheet : DependencyObject, IMapStyleSheetpublic sealed class MapStyleSheet : DependencyObject, IMapStyleSheetPublic NotInheritable Class MapStyleSheet Inherits DependencyObject Implements IMapStyleSheet
Inheritance
MapStyleSheetMapStyleSheetMapStyleSheet
Attributes
Windows 10 requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Inherited Members

Inherited methods

Inherited properties

Methods

Aerial() Aerial() Aerial()

Gets a MapStyleSheet that presents an areal view of the map.

public static MapStyleSheet Aerial()public static MapStyleSheet Aerial()Public Static Function Aerial() As MapStyleSheet
Returns

A MapStyleSheet that presents an areal view of the map.

Attributes

AerialWithOverlay() AerialWithOverlay() AerialWithOverlay()

Gets a MapStyleSheet that presents a hybrid map that combines an aerial map with roads.

public static MapStyleSheet AerialWithOverlay()public static MapStyleSheet AerialWithOverlay()Public Static Function AerialWithOverlay() As MapStyleSheet
Returns

A MapStyleSheet that presents a hybrid map that combines an aerial map with roads.

Attributes

Combine(IIterable<MapStyleSheet>) Combine(IIterable<MapStyleSheet>) Combine(IIterable<MapStyleSheet>)

Combines the rules defined in two MapStyleSheet instances.

public static MapStyleSheet Combine(IIterable<MapStyleSheet> styleSheets)public static MapStyleSheet Combine(IIterable<MapStyleSheet> styleSheets)Public Static Function Combine(styleSheets As IIterable<MapStyleSheet>) As MapStyleSheet
Parameters
styleSheets

The MapStyleSheet instances that you want to combine.

Returns

A MapStyleSheet instance that contains the combined rules defined in each MapStyleSheet instance that you passed to the styleSheets parameter.

Attributes

Remarks

If both MapStyleSheet instances define the same rule, the last instance will override the rule defined in the first instance.

Examples

The following example combines rules from two MapStyleSheet instances into one MapStyleSheet instance.

To learn more about the properties used in this example, see Map stylesheet reference.

string jsonString = @"{

  ""version"": ""1.*"",

  ""settings"": {

    ""rasterRegionsVisible"":true,

    ""spaceColor"":""#000000""

    },

  ""elements"":{

    ""majorRoad"":{

      ""labelColor"":""#490B7D"",

      ""labelScale"":1.5,

      ""font"": ""Comic Sans MS""

    }

  }

}";


string jsonString2 = @"{

  ""version"": ""1.*"",

  ""settings"":{

    ""landColor"":""#FFC8DD""

  }

}";


MapStyleSheet myCustomStyleSheet = MapStyleSheet.ParseFromJson(jsonString);
MapStyleSheet myCustomStyleSheet2 = MapStyleSheet.ParseFromJson(jsonString2);


List<MapStyleSheet> myList = new List<MapStyleSheet>();
myList.Add(myCustomStyleSheet);
myList.Add(myCustomStyleSheet2);


myMap.StyleSheet = MapStyleSheet.Combine(myList);

ParseFromJson(String) ParseFromJson(String) ParseFromJson(String)

Creates a stylesheet by parsing a JSON markup string that defines a set of custom rules.

public static MapStyleSheet ParseFromJson(String styleAsJson)public static MapStyleSheet ParseFromJson(String styleAsJson)Public Static Function ParseFromJson(styleAsJson As String) As MapStyleSheet
Parameters
styleAsJson
System.String System.String System.String

A JSON markup string that defines a set of custom rules.

Returns

A MapStyleSheet that represents the rules defined in JSON markup string.

Attributes

Remarks

Examples

The following example uses the ParseFromJson method to create a MapStyleSheet and then applies that style sheet to the map control.

To learn more about the properties used in this example, see Map stylesheet reference.

string jsonString = @"{

  ""version"": ""1.*"",

  ""settings"":{

    ""rasterRegionsVisible"":true,

    ""spaceColor"":""#000000""

  },

  ""elements"":{

    ""majorRoad"":{

      ""labelColor"":""#490B7D"",

      ""labelScale"":1.5,

      ""font"": ""Comic Sans MS""

    }

  }

}";


MapStyleSheet myCustomStyleSheet = MapStyleSheet.ParseFromJson(jsonString);
myMap.StyleSheet = myCustomStyleSheet;

RoadDark() RoadDark() RoadDark()

Gets a MapStyleSheet that presents a road map with a dark theme.

public static MapStyleSheet RoadDark()public static MapStyleSheet RoadDark()Public Static Function RoadDark() As MapStyleSheet
Returns

A MapStyleSheet that presents a road map with a dark theme.

Attributes

RoadHighContrastDark() RoadHighContrastDark() RoadHighContrastDark()

Gets a MapStyleSheet styles the map with a high contrast dark theme.

public static MapStyleSheet RoadHighContrastDark()public static MapStyleSheet RoadHighContrastDark()Public Static Function RoadHighContrastDark() As MapStyleSheet
Returns

A MapStyleSheet styles the map with a high contrast dark theme.

Attributes

Remarks

High contrast themes use a small palette of contrasting colors that makes the interface easier to see.

See High contrast themes.

RoadHighContrastLight() RoadHighContrastLight() RoadHighContrastLight()

Gets a MapStyleSheet styles the map with a high contrast light theme.

public static MapStyleSheet RoadHighContrastLight()public static MapStyleSheet RoadHighContrastLight()Public Static Function RoadHighContrastLight() As MapStyleSheet
Returns

A MapStyleSheet styles the map with a high contrast light theme.

Attributes

Remarks

High contrast themes use a small palette of contrasting colors that makes the interface easier to see.

See High contrast themes.

RoadLight() RoadLight() RoadLight()

Gets a MapStyleSheet that presents a road map with a light theme.

public static MapStyleSheet RoadLight()public static MapStyleSheet RoadLight()Public Static Function RoadLight() As MapStyleSheet
Returns

A MapStyleSheet that presents a road map with a light theme.

Attributes

TryParseFromJson(String, MapStyleSheet) TryParseFromJson(String, MapStyleSheet) TryParseFromJson(String, MapStyleSheet)

Creates stylesheet by parsing a JSON markup string that defines a set of custom rules.

public static bool TryParseFromJson(String styleAsJson, MapStyleSheet styleSheet)public static bool TryParseFromJson(String styleAsJson, MapStyleSheet styleSheet)Public Static Function TryParseFromJson(styleAsJson As String, styleSheet As MapStyleSheet) As bool
Parameters
styleAsJson
System.String System.String System.String

A JSON markup string that defines a set of custom rules.

styleSheet
MapStyleSheet MapStyleSheet MapStyleSheet

The MapStyleSheet that will represent the rules defined in JSON markup string.

Returns
bool bool bool

true if the operation completed successfully; otherwise, false.

Attributes

Remarks

To learn more about the properties that you can use in your JSON string to define styles, see Map stylesheet reference.

If there's an error in the JSON markup string, this method does not throw an exception. Instead, it returns false.