decode static method
Implementation
static LocationIndicatorLayer decode(String properties) {
var map = json.decode(properties);
if (map["layout"] == null) {
map["layout"] = {};
}
if (map["paint"] == null) {
map["paint"] = {};
}
return LocationIndicatorLayer(
id: map["id"],
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"])),
bearingImage: map["layout"]["bearing-image"] is String?
? map["layout"]["bearing-image"] as String?
: null,
shadowImage: map["layout"]["shadow-image"] is String?
? map["layout"]["shadow-image"] as String?
: null,
topImage: map["layout"]["top-image"] is String?
? map["layout"]["top-image"] as String?
: null,
accuracyRadius: map["paint"]["accuracy-radius"] is num?
? (map["paint"]["accuracy-radius"] as num?)?.toDouble()
: null,
accuracyRadiusBorderColor:
(map["paint"]["accuracy-radius-border-color"] as List?)?.toRGBAInt(),
accuracyRadiusColor:
(map["paint"]["accuracy-radius-color"] as List?)?.toRGBAInt(),
bearing: map["paint"]["bearing"] is num?
? (map["paint"]["bearing"] as num?)?.toDouble()
: null,
bearingImageSize: map["paint"]["bearing-image-size"] is num?
? (map["paint"]["bearing-image-size"] as num?)?.toDouble()
: null,
emphasisCircleColor:
(map["paint"]["emphasis-circle-color"] as List?)?.toRGBAInt(),
emphasisCircleRadius: map["paint"]["emphasis-circle-radius"] is num?
? (map["paint"]["emphasis-circle-radius"] as num?)?.toDouble()
: null,
imagePitchDisplacement: map["paint"]["image-pitch-displacement"] is num?
? (map["paint"]["image-pitch-displacement"] as num?)?.toDouble()
: null,
location: (map["paint"]["location"] as List?)
?.map<double?>((e) => e.toDouble())
.toList(),
perspectiveCompensation: map["paint"]["perspective-compensation"] is num?
? (map["paint"]["perspective-compensation"] as num?)?.toDouble()
: null,
shadowImageSize: map["paint"]["shadow-image-size"] is num?
? (map["paint"]["shadow-image-size"] as num?)?.toDouble()
: null,
topImageSize: map["paint"]["top-image-size"] is num?
? (map["paint"]["top-image-size"] as num?)?.toDouble()
: null,
);
}