decode static method

HillshadeLayer decode(
  1. String properties
)

Implementation

static HillshadeLayer decode(String properties) {
  var map = json.decode(properties);
  if (map["layout"] == null) {
    map["layout"] = {};
  }
  if (map["paint"] == null) {
    map["paint"] = {};
  }
  return HillshadeLayer(
    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"])),
    hillshadeAccentColor:
        (map["paint"]["hillshade-accent-color"] as List?)?.toRGBAInt(),
    hillshadeEmissiveStrength: map["paint"]["hillshade-emissive-strength"]
            is num?
        ? (map["paint"]["hillshade-emissive-strength"] as num?)?.toDouble()
        : null,
    hillshadeExaggeration: map["paint"]["hillshade-exaggeration"] is num?
        ? (map["paint"]["hillshade-exaggeration"] as num?)?.toDouble()
        : null,
    hillshadeHighlightColor:
        (map["paint"]["hillshade-highlight-color"] as List?)?.toRGBAInt(),
    hillshadeIlluminationAnchor:
        map["paint"]["hillshade-illumination-anchor"] == null
            ? null
            : HillshadeIlluminationAnchor.values.firstWhere((e) => e.name
                .toLowerCase()
                .replaceAll("_", "-")
                .contains(map["paint"]["hillshade-illumination-anchor"])),
    hillshadeIlluminationDirection:
        map["paint"]["hillshade-illumination-direction"] is num?
            ? (map["paint"]["hillshade-illumination-direction"] as num?)
                ?.toDouble()
            : null,
    hillshadeShadowColor:
        (map["paint"]["hillshade-shadow-color"] as List?)?.toRGBAInt(),
  );
}