Visualizing KML data on a map requires two steps:

  1. Create a KMLModel by loading a KML file.

  2. Use a KMLLayer to visualize the model.

//First decode the data into a model
const model = new KMLModel(url);

//Create a layer for the model
//The layer visualizes the KML data using the
//styling information provided in the data
const layer = new KMLLayer(model);

//Add the layer to the map
map.layerTree.addChild(layer);