This is the very stripped down version of how to display kml.
I have one function display_map. I have stripped the options to a minimum.
Instead of adding a listener - I simply call the function in the body onload.
This page violates some JSFiddle rules - but it is for demonstration.