I am creating a number of kml layers and adding them async to my map. The problem is, is that I can't figure out how to create their legend info so that they can be displayed on my legend to the map. I want to do something like this, but can't figure out how to get anything to work at all. i know I need to add to the legendinfos of the layer or the map itself, but hit a roadblock.
This append below doesn't work at all, but shows what I am trying to do.
var newKMLLayer = ArcGISRuntimeEnvironment.createObject("KmlLayer",
{
dataset: newKMLDataset,
id: kmlLayer,
description: inName,
layerId: "LayerID",
name: inName,
maxScale: 0,
minScale: 0,
visible: false
});
newKMLLayer.legendInfos.append({
"layerName": inName,
"symbolURL": "URL"
})
mapViewFieldSelected.map.operationalLayers.append(newKMLLayer)
You'll probably need to handle KML Layers as a special case in your TOC, as they function differently than most other layers. The concept of LegendInfos doesn't really apply to them. TO build a TOC, you will need to go down the the node hierarchy (starting from the dataset rootNodes and using the container or networklink childNodes to go down) and use the KmlNode.UXIcon + KmlNode.Name (for example) to create a TOC entry