decode static method

HeatmapLayer decode(
  1. String properties
)

Implementation

static HeatmapLayer decode(String properties) {
  var map = json.decode(properties);
  if (map["layout"] == null) {
    map["layout"] = {};
  }
  if (map["paint"] == null) {
    map["paint"] = {};
  }
  return HeatmapLayer(
    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"]),
          ),
    visibilityExpression: styleOptionalCastList(map["layout"]["visibility"]),
    filter: styleOptionalCastList(map["filter"]),
    heatmapColor: (map["paint"]["heatmap-color"] as List?)?.toRGBAInt(),
    heatmapColorExpression: styleOptionalCastList(
      map["paint"]["heatmap-color"],
    ),
    heatmapIntensity: styleOptionalCast(map["paint"]["heatmap-intensity"]),
    heatmapIntensityExpression: styleOptionalCastList(
      map["paint"]["heatmap-intensity"],
    ),
    heatmapOpacity: styleOptionalCast(map["paint"]["heatmap-opacity"]),
    heatmapOpacityExpression: styleOptionalCastList(
      map["paint"]["heatmap-opacity"],
    ),
    heatmapRadius: styleOptionalCast(map["paint"]["heatmap-radius"]),
    heatmapRadiusExpression: styleOptionalCastList(
      map["paint"]["heatmap-radius"],
    ),
    heatmapWeight: styleOptionalCast(map["paint"]["heatmap-weight"]),
    heatmapWeightExpression: styleOptionalCastList(
      map["paint"]["heatmap-weight"],
    ),
  );
}