MapStyleSheet 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// This API is not available in Javascript.
Inheritance
MapStyleSheetMapStyleSheetMapStyleSheetMapStyleSheet
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() Aerial()

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

public : static MapStyleSheet Aerial()public static MapStyleSheet Aerial()Public Static Function Aerial() As MapStyleSheet// This API is not available in Javascript.
Returns

A MapStyleSheet that presents an aerial view of the map.

AerialWithOverlay() 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// This API is not available in Javascript.
Returns

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

Combine(IIterable) Combine(IIterable) Combine(IIterable) Combine(IIterable)

Combines the rules defined in two MapStyleSheet instances.

public : static MapStyleSheet Combine(IIterable<MapStyleSheet> styleSheets)public static MapStyleSheet Combine(IEnumerable<MapStyleSheet> styleSheets)Public Static Function Combine(styleSheets As IEnumerable<MapStyleSheet>) As MapStyleSheet// This API is not available in Javascript.
Parameters
styleSheets
IIterable<MapStyleSheet> IEnumerable<MapStyleSheet> IEnumerable<MapStyleSheet> IEnumerable<MapStyleSheet>

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.

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);

Remarks

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

ParseFromJson(String) 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(PlatForm::String styleAsJson)public static MapStyleSheet ParseFromJson(String styleAsJson)Public Static Function ParseFromJson(styleAsJson As String) As MapStyleSheet// This API is not available in Javascript.
Parameters
styleAsJson
PlatForm::String String String String

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

Returns

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

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() 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// This API is not available in Javascript.
Returns

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

RoadHighContrastDark() 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// This API is not available in Javascript.
Returns

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

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() 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// This API is not available in Javascript.
Returns

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

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() 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// This API is not available in Javascript.
Returns

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

TryParseFromJson(String, MapStyleSheet) 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 PlatForm::Boolean TryParseFromJson(PlatForm::String styleAsJson, MapStyleSheet styleSheet)public static bool TryParseFromJson(String styleAsJson, MapStyleSheet styleSheet)Public Static Function TryParseFromJson(styleAsJson As String, styleSheet As MapStyleSheet) As bool// This API is not available in Javascript.
Parameters
styleAsJson
PlatForm::String String String String

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

styleSheet
MapStyleSheet MapStyleSheet MapStyleSheet MapStyleSheet

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

Returns
PlatForm::Boolean bool bool bool

true if the operation completed successfully; otherwise, false.

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.