decode static method
Implementation
static CircleLayer decode(String properties) {
var map = json.decode(properties);
if (map["layout"] == null) {
map["layout"] = {};
}
if (map["paint"] == null) {
map["paint"] = {};
}
return CircleLayer(
id: map["id"],
sourceId: map["source"],
sourceLayer: map["source-layer"],
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"])),
circleSortKey: map["layout"]["circle-sort-key"] is num?
? (map["layout"]["circle-sort-key"] as num?)?.toDouble()
: null,
circleBlur: map["paint"]["circle-blur"] is num?
? (map["paint"]["circle-blur"] as num?)?.toDouble()
: null,
circleColor: (map["paint"]["circle-color"] as List?)?.toRGBAInt(),
circleEmissiveStrength: map["paint"]["circle-emissive-strength"] is num?
? (map["paint"]["circle-emissive-strength"] as num?)?.toDouble()
: null,
circleOpacity: map["paint"]["circle-opacity"] is num?
? (map["paint"]["circle-opacity"] as num?)?.toDouble()
: null,
circlePitchAlignment: map["paint"]["circle-pitch-alignment"] == null
? null
: CirclePitchAlignment.values.firstWhere((e) => e.name
.toLowerCase()
.replaceAll("_", "-")
.contains(map["paint"]["circle-pitch-alignment"])),
circlePitchScale: map["paint"]["circle-pitch-scale"] == null
? null
: CirclePitchScale.values.firstWhere((e) => e.name
.toLowerCase()
.replaceAll("_", "-")
.contains(map["paint"]["circle-pitch-scale"])),
circleRadius: map["paint"]["circle-radius"] is num?
? (map["paint"]["circle-radius"] as num?)?.toDouble()
: null,
circleStrokeColor:
(map["paint"]["circle-stroke-color"] as List?)?.toRGBAInt(),
circleStrokeOpacity: map["paint"]["circle-stroke-opacity"] is num?
? (map["paint"]["circle-stroke-opacity"] as num?)?.toDouble()
: null,
circleStrokeWidth: map["paint"]["circle-stroke-width"] is num?
? (map["paint"]["circle-stroke-width"] as num?)?.toDouble()
: null,
circleTranslate: (map["paint"]["circle-translate"] as List?)
?.map<double?>((e) => e.toDouble())
.toList(),
circleTranslateAnchor: map["paint"]["circle-translate-anchor"] == null
? null
: CircleTranslateAnchor.values.firstWhere((e) => e.name
.toLowerCase()
.replaceAll("_", "-")
.contains(map["paint"]["circle-translate-anchor"])),
);
}