The code looks AOK apart from the line
<script src="https://www.google.com/jsapi?key=YOURAPIKEY"></script>
Really it should either have your api key in the query, or else simply be
<script src="https://www.google.com/jsapi"></script>
As it is, it could be that you are simply getting an invalid API key error.
If that doesn't solve it could you post a link to your actual site where it isn't working?