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(),
visibility: map["layout"]["visibility"] == null
? Visibility.VISIBLE
: Visibility.values.firstWhere((e) => e
.toString()
.split('.')
.last
.toLowerCase()
.contains(map["layout"]["visibility"])),
circleSortKey: map["layout"]["circle-sort-key"]?.toDouble(),
circleBlur: map["paint"]["circle-blur"]?.toDouble(),
circleColor: (map["paint"]["circle-color"] as List?)?.toRGBAInt(),
circleOpacity: map["paint"]["circle-opacity"]?.toDouble(),
circlePitchAlignment: map["paint"]["circle-pitch-alignment"] == null
? null
: CirclePitchAlignment.values.firstWhere((e) => e
.toString()
.split('.')
.last
.toLowerCase()
.contains(map["paint"]["circle-pitch-alignment"])),
circlePitchScale: map["paint"]["circle-pitch-scale"] == null
? null
: CirclePitchScale.values.firstWhere((e) => e
.toString()
.split('.')
.last
.toLowerCase()
.contains(map["paint"]["circle-pitch-scale"])),
circleRadius: map["paint"]["circle-radius"]?.toDouble(),
circleStrokeColor:
(map["paint"]["circle-stroke-color"] as List?)?.toRGBAInt(),
circleStrokeOpacity: map["paint"]["circle-stroke-opacity"]?.toDouble(),
circleStrokeWidth: map["paint"]["circle-stroke-width"]?.toDouble(),
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
.toString()
.split('.')
.last
.toLowerCase()
.contains(map["paint"]["circle-translate-anchor"])),
);
}