Click here to Skip to main content
15,896,726 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using geolocation api to get latitude and longitude of place i am in.. here is my code..

XML
<script type='text/javascript'>
          var x = document.getElementById('add');
          var c = function (pos) {
              var latitude = pos.coords.latitude;
              var longitude = pos.coords.longitude;
              coords = latitude + ',' + longitude;
              document.getElementById('google_map').setAttribute('src', 'https://maps.google.com.np/?q=' + coords + '&z=20&output=embed');
              x.innerHTML = "lat:" + latitude + "<br /> long: " + longitude;
      }
<pre lang="cs">document.getElementById('get_location').onclick = function () {
              if (navigator.geolocation) {
                  navigator.geolocation.getCurrentPosition(c);
                  return false;
              } else {
                  alert("Geo Location is not supported on your current browser!");
              }
          }
      </script>


here pos.coords.latitude & pos.coords.longitude returns my latitude and longitude but the problem is sometimes it returns full value ie. my degree, minutes and seconds showing me in the exact place where i am and sometimes it returns only my degree and round off value in minutes resulting to show me is different place where i am not.. how can i get full value and avoid round off value via coding??

anyway thanks in advance..
Posted

1 solution

 
Share this answer
 
Comments
Codes DeCodes 9-Apr-14 3:31am    
thanks for the link man...
Richard MacCutchan 9-Apr-14 3:43am    
Not very difficult for Google to find.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900