Map styles
MapKit allows you to change the appearance of the displayed map, its saturation, brightness and hue.
How to set the map style
The map style is defined by using a JSON string that looks like this:
[
{
"featureType" : "string",
"stylers" : {
"hue" : "double",
"saturation" : "double",
"lightness" : "double"
}
}
]
Attention. Required request parameters are marked with an asterisk (*).
featureType
*The class of the object to which you want to apply the styles. To apply styles to all features on a layer, set the value to
all
.stylers
Map style to use, in HSV format.
hue
Changes the hue of the objects on the map. Possible values: -1 to 1.
Examples:
"hue": 0.5
"hue": -0.5
saturation
Changes the color saturation of the map. Possible values: -1 to 1.
Examples:
"saturation": 1
"saturation": -1
lightness
Changes the brightness of the colors on the map. Possible values: -1 to 1.
Examples:
"lightness": 0.5
"lightness": -0.5
* Required
How to apply map styles
To apply styles to a map, use the following methods:
setMapStyle
for the main map layer.setTrafficStyle
for the traffic layer.
String style = "[" +
" {" +
" \"featureType\" : \"all\"," +
" \"stylers\" : {" +
" \"hue\" : \"1\"," +
" \"saturation\" : \"0.3\"," +
" \"lightness\" : \"-0.7\"" +
" }" +
" }" +
"]";
mapview.getMap().setMapStyle(style);
mapview.getMap().getTrafficLayer().setTrafficStyleWithStyle(style);
NSString *style = @"["
"{"
"\featureType\" : \"all\","
"\"stylers\" : {"
"\"hue\" : \"1\","
"\"saturation\" : \"0.3\","
"\"lightness\" : \"-0.7\""
"}"
"}"
"]";
[[YMKMap Mapview] setMapStyleWithStyle:style];
[[YMKTrafficLayer Traffic] setTrafficStyleWithStyle:style];