title: Google Maps Api v3 - wrong location on map plot load
body: <p>I need help for my google map api in my website. I included the map in my website and then automatically plots my location or locate me, but the problem is it gives me wrong location but some location are correct.</p>
  
  <p>This is my website : <code>http://webserver.site88.net/beta-test</code></p>
  
  <p><strong>Here is mycode:</strong></p>
  
  
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function writeAddressName(latLng) {
      var geocoder = new google.maps.Geocoder();
      geocoder.geocode({
        "location": latLng
      },
      function(results, status) {
        if (status == google.maps.GeocoderStatus.OK)
          document.getElementById("address").value = results[0].formatted_address;
        else
          document.getElementById("error").innerHTML += "Unable to retrieve your address" + "&lt;br /&gt;";
      });
    }
  
    function geolocationSuccess(position) {
      var userLatLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
      document.getElementById("inLat").value = position.coords.latitude;
      document.getElementById("inLong").value = position.coords.longitude;
  
      // Write the formatted address
      writeAddressName(userLatLng);
  
      var myOptions = {
        zoom : 16,
        center : userLatLng,
        mapTypeId : google.maps.MapTypeId.ROADMAP,
        location_type: google.maps.GeocoderLocationType.ROOFTOP
      };
      // Draw the map
      var mapObject = new google.maps.Map(document.getElementById("map"), myOptions);
      // Place the marker
      var marker = new google.maps.Marker({
        map: mapObject,
        position: userLatLng
      });
  
      var infowindow = new google.maps.InfoWindow({
      content: '&lt;div&gt;'+'&lt;b&gt;'+'You are here '+'&lt;/b&gt;'+'&lt;/div&gt;'
      });
  
  
      infowindow.open(mapObject,marker);
  
      google.maps.event.addDomListener(window, 'load', geolocateUser);
    }
  
    function geolocationError(positionError) {
      document.getElementById("error").innerHTML += "Error: " + positionError.message + "&lt;br /&gt;";
    }
  
    function geolocateUser() {
      // If the browser supports the Geolocation API
      if (navigator.geolocation)
      {
        var positionOptions = {
          enableHighAccuracy: true,
          timeout: 10 * 1000 // 10 seconds
        };
        navigator.geolocation.getCurrentPosition(geolocationSuccess, geolocationError, positionOptions);
      }
      else
        document.getElementById("error").innerHTML += "Your browser doesn't support the Geolocation API";
  
  
  }
  &lt;/script&gt;
  </code></pre>