title: Add Marker function with Google Maps API
body: <p>I have the following Javascript that includes both the standard Google Maps API <code>initialize()</code> function and custom <code>addMarker()</code> function. The map will load fine however the marker does not get added to the map. </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
      // Standard google maps function
      function initialize() {
          var myLatlng = new google.maps.LatLng(40.779502, -73.967857);
          var myOptions = {
              zoom: 12,
              center: myLatlng,
              mapTypeId: google.maps.MapTypeId.ROADMAP
          }
          map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
      }
  
      // Function for adding a marker to the page.
      function addMarker(location) {
          marker = new google.maps.Marker({
              position: location,
              map: map
          });
      }
  
      // Testing the addMarker function
      CentralPark = new google.maps.LatLng(37.7699298, -122.4469157);
      addMarker(CentralPark);
  
  &lt;/script&gt;
  </code></pre>