MapStyleSheet.ParseFromJson(String) Method

Definition

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

public:
 static MapStyleSheet ^ ParseFromJson(Platform::String ^ styleAsJson);
 static MapStyleSheet ParseFromJson(winrt::hstring const& styleAsJson);
public static MapStyleSheet ParseFromJson(string styleAsJson);
function parseFromJson(styleAsJson)
Public Shared Function ParseFromJson (styleAsJson As String) As MapStyleSheet

Parameters

styleAsJson
String

Platform::String

winrt::hstring

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;

Applies to