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(),
    visibility: map["layout"]["visibility"] == null
        ? Visibility.VISIBLE
        : Visibility.values.firstWhere((e) => e
            .toString()
            .split('.')
            .last
            .toLowerCase()
            .contains(map["layout"]["visibility"])),
    heatmapColor: (map["paint"]["heatmap-color"] as List?)?.toRGBAInt(),
    heatmapIntensity: map["paint"]["heatmap-intensity"] is num?
        ? (map["paint"]["heatmap-intensity"] as num?)?.toDouble()
        : null,
    heatmapOpacity: map["paint"]["heatmap-opacity"] is num?
        ? (map["paint"]["heatmap-opacity"] as num?)?.toDouble()
        : null,
    heatmapRadius: map["paint"]["heatmap-radius"] is num?
        ? (map["paint"]["heatmap-radius"] as num?)?.toDouble()
        : null,
    heatmapWeight: map["paint"]["heatmap-weight"] is num?
        ? (map["paint"]["heatmap-weight"] as num?)?.toDouble()
        : null,
  );
}