getLayer method

Future<Layer?> getLayer(
  1. String layerId
)

Get a previously added layer from the current style.

Implementation

Future<Layer?> getLayer(String layerId) async {
  var properties = await getStyleLayerProperties(layerId);

  Layer? layer;
  var map = json.decode(properties);

  var type = map["type"];
  switch (type) {
    case "background":
      layer = BackgroundLayer.decode(properties);
      break;
    case "location-indicator":
      layer = LocationIndicatorLayer.decode(properties);
      break;
    case "sky":
      layer = SkyLayer.decode(properties);
      break;
    case "circle":
      layer = CircleLayer.decode(properties);
      break;
    case "fill-extrusion":
      layer = FillExtrusionLayer.decode(properties);
      break;
    case "fill":
      layer = FillLayer.decode(properties);
      break;
    case "heatmap":
      layer = HeatmapLayer.decode(properties);
      break;
    case "hillshade":
      layer = HillshadeLayer.decode(properties);
      break;
    case "line":
      layer = LineLayer.decode(properties);
      break;
    case "raster":
      layer = RasterLayer.decode(properties);
      break;
    case "symbol":
      layer = SymbolLayer.decode(properties);
      break;
    case "model":
      layer = ModelLayer.decode(properties);
      break;
    case "slot":
      layer = SlotLayer.decode(properties);
      break;
    case "raster-particle":
      layer = RasterParticleLayer.decode(properties);
      break;
    case "clip":
      layer = ClipLayer.decode(properties);
      break;
    default:
      print("Layer type: $type unknown.");
  }

  return Future.value(layer);
}