WMS includes a
GetLegendGraphic operation which allows a WMS client to obtain a legend graphic from the server for a particular layer. Combining the legend with KML overlays allows the legend to be viewed inside Google Earth.
To get GeoServer to include a legend with the KML output, append
legend=true to the KML reflector request. For example:
The resulting Google Earth output looks like this: