MapStyleSheet MapStyleSheet MapStyleSheet MapStyleSheet Class

Definition

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

public : sealed class MapStyleSheet : DependencyObject, IMapStyleSheet
struct winrt::Windows::UI::Xaml::Controls::Maps::MapStyleSheet : DependencyObject, IMapStyleSheet
public sealed class MapStyleSheet : DependencyObject, IMapStyleSheet
Public NotInheritable Class MapStyleSheet Inherits DependencyObject Implements IMapStyleSheet
Inheritance
MapStyleSheetMapStyleSheetMapStyleSheetMapStyleSheet
Attributes
Windows 10 requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Methods

Aerial() Aerial() Aerial() Aerial()

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

public : static MapStyleSheet Aerial()
MapStyleSheet Aerial() const;
public static MapStyleSheet Aerial()
Public Static Function Aerial() As MapStyleSheet
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()
MapStyleSheet AerialWithOverlay() const;
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.

ClearValue(DependencyProperty) ClearValue(DependencyProperty) ClearValue(DependencyProperty) ClearValue(DependencyProperty)

Clears the local value of a dependency property.

(Inherited from DependencyObject)

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

Combines the rules defined in two MapStyleSheet instances.

public : static MapStyleSheet Combine(IIterable<MapStyleSheet> styleSheets)
MapStyleSheet Combine(IIterable<MapStyleSheet> styleSheets) const;
public static MapStyleSheet Combine(IEnumerable<MapStyleSheet> styleSheets)
Public Static Function Combine(styleSheets As IEnumerable<MapStyleSheet>) As MapStyleSheet
Parameters
styleSheets
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.

GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty)

Returns any base value established for a dependency property, which would apply in cases where an animation is not active.

(Inherited from DependencyObject)

GetValue(DependencyProperty) GetValue(DependencyProperty) GetValue(DependencyProperty) GetValue(DependencyProperty)

Returns the current effective value of a dependency property from a DependencyObject.

(Inherited from DependencyObject)

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)
MapStyleSheet ParseFromJson(winrt::hstring styleAsJson) const;
public static MapStyleSheet ParseFromJson(String styleAsJson)
Public Static Function ParseFromJson(styleAsJson As String) As MapStyleSheet
Parameters
styleAsJson
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;

ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty)

Returns the local value of a dependency property, if a local value is set.

(Inherited from DependencyObject)

RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback)

Registers a notification function for listening to changes to a specific DependencyProperty on this DependencyObject instance.

(Inherited from DependencyObject)

RoadDark() RoadDark() RoadDark() RoadDark()

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

public : static MapStyleSheet RoadDark()
MapStyleSheet RoadDark() const;
public static MapStyleSheet RoadDark()
Public Static Function RoadDark() As MapStyleSheet
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()
MapStyleSheet RoadHighContrastDark() const;
public static MapStyleSheet RoadHighContrastDark()
Public Static Function RoadHighContrastDark() As MapStyleSheet
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()
MapStyleSheet RoadHighContrastLight() const;
public static MapStyleSheet RoadHighContrastLight()
Public Static Function RoadHighContrastLight() As MapStyleSheet
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()
MapStyleSheet RoadLight() const;
public static MapStyleSheet RoadLight()
Public Static Function RoadLight() As MapStyleSheet
Returns

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

SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object)

Sets the local value of a dependency property on a DependencyObject.

(Inherited from DependencyObject)

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)
bool TryParseFromJson(winrt::hstring styleAsJson, MapStyleSheet styleSheet) const;
public static bool TryParseFromJson(String styleAsJson, MapStyleSheet styleSheet)
Public Static Function TryParseFromJson(styleAsJson As String, styleSheet As MapStyleSheet) As bool
Parameters
styleAsJson
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
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.

UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64)

Cancels a change notification that was previously registered by calling RegisterPropertyChangedCallback.

(Inherited from DependencyObject)

Properties

Dispatcher Dispatcher Dispatcher Dispatcher

Gets the CoreDispatcher that this object is associated with. The CoreDispatcher represents a facility that can access the DependencyObject on the UI thread even if the code is initiated by a non-UI thread.

(Inherited from DependencyObject)