title: Google maps API - Center map on client's current location
body: <p>I've looked at the various other times this question has been asked but I can't quite put a finger on where I'm going wrong, here's my code:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt; Map &lt;/title&gt;
      &lt;style&gt;
          html, body, #map-canvas {
          margin: 0;
          padding: 0;
          height: 500px;
          width: 800px;}
      &lt;/style&gt;
      &lt;script src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false"&gt;&lt;/script&gt;
      &lt;script&gt;
          var map;
          function initialize()
          {
              var myLatlng1 = new google.maps.LatLng(53.65914, 0.072050);
  
              var mapOptions = 
              {
                  zoom: 10,
                  center: myLatlng1,
                  mapTypeId: google.maps.MapTypeId.ROADMAP
              };
              var map = new google.maps.Map(document.getElementById('map-canvas'),
              mapOptions);
  
  
              &lt;?php
                  $sql = mysql_query("SELECT * FROM data ORDER BY ID DESC");
                  while($row =mysql_fetch_array($sql))
                  {
                      $desc = $row['DESCRIPTION'];
                      $location = $row['LOCATION'];
                      $counter += 1; 
                  ?&gt;
  
              var marker = new google.maps.Marker({
                  position: new google.maps.LatLng(&lt;?php echo $location; ?&gt;),
                  map: map,
                  title: '&lt;?php echo $desc; ?&gt;',
                  icon: '/image/cam.png'
              });
  
             navigator.geolocation.getCurrentPosition(showPosition);  
          }
  
          var showPosition = function (position) 
             {
                 map.setCenter(new google.maps.LatLng(position.coords.latitude, position.coords.longitude), 16);
  
             }
  
          google.maps.event.addDomListener(window, 'load', initialize);
  
      &lt;/script&gt;
  &lt;/head&gt;
  </code></pre>
  
  <p>It originally sets the center to myLatlng1, and the code at the bottom to set it to the user's current location doesn't do anything, any ideas?</p>
  
  <p>Thanks in advance.</p>