decode static method
Implementation
static SkyLayer decode(String properties) {
var map = json.decode(properties);
if (map["layout"] == null) {
map["layout"] = {};
}
if (map["paint"] == null) {
map["paint"] = {};
}
return SkyLayer(
id: map["id"],
minZoom: map["minzoom"]?.toDouble(),
maxZoom: map["maxzoom"]?.toDouble(),
slot: map["slot"],
visibility: map["layout"]["visibility"] == null
? Visibility.VISIBLE
: Visibility.values.firstWhere((e) => e.name
.toLowerCase()
.replaceAll("_", "-")
.contains(map["layout"]["visibility"])),
visibilityExpression: _optionalCastList(map["layout"]["visibility"]),
filter: _optionalCastList(map["filter"]),
skyAtmosphereColor:
(map["paint"]["sky-atmosphere-color"] as List?)?.toRGBAInt(),
skyAtmosphereColorExpression:
_optionalCastList(map["paint"]["sky-atmosphere-color"]),
skyAtmosphereHaloColor:
(map["paint"]["sky-atmosphere-halo-color"] as List?)?.toRGBAInt(),
skyAtmosphereHaloColorExpression:
_optionalCastList(map["paint"]["sky-atmosphere-halo-color"]),
skyAtmosphereSun: (map["paint"]["sky-atmosphere-sun"] as List?)
?.map<double?>((e) => e.toDouble())
.toList(),
skyAtmosphereSunExpression:
_optionalCastList(map["paint"]["sky-atmosphere-sun"]),
skyAtmosphereSunIntensity:
_optionalCast(map["paint"]["sky-atmosphere-sun-intensity"]),
skyAtmosphereSunIntensityExpression:
_optionalCastList(map["paint"]["sky-atmosphere-sun-intensity"]),
skyGradient: (map["paint"]["sky-gradient"] as List?)?.toRGBAInt(),
skyGradientExpression: _optionalCastList(map["paint"]["sky-gradient"]),
skyGradientCenter: (map["paint"]["sky-gradient-center"] as List?)
?.map<double?>((e) => e.toDouble())
.toList(),
skyGradientCenterExpression:
_optionalCastList(map["paint"]["sky-gradient-center"]),
skyGradientRadius: _optionalCast(map["paint"]["sky-gradient-radius"]),
skyGradientRadiusExpression:
_optionalCastList(map["paint"]["sky-gradient-radius"]),
skyOpacity: _optionalCast(map["paint"]["sky-opacity"]),
skyOpacityExpression: _optionalCastList(map["paint"]["sky-opacity"]),
skyType: map["paint"]["sky-type"] == null
? null
: SkyType.values.firstWhere((e) => e.name
.toLowerCase()
.replaceAll("_", "-")
.contains(map["paint"]["sky-type"])),
skyTypeExpression: _optionalCastList(map["paint"]["sky-type"]),
);
}