2

I am inserting latitude and longitude values into a database table, but some browser giving big values with decimal and some are giving less below is the values. And some Firefox version GEO map is not coming and some buddy told that add {timeout: 5000}, if browser will not support means will give alert. But not getting to add that value in my Java Script function.

     Latitude                     Longitude 

 1. 17.442816099999998          78.4800497          // this values are coming from firefox

 2.  17.4428978                 78.4799792         // this values are coming from google crome

The above Firefox values are correct and that is my exact location. I need Latitude values should come full after decimal 15 digits should come like above number 1 values in google chrome.

Below is my javascript code:

  <script type="text/javascript">


if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(success );
}
else 
{
    alert("Geo Location is not supported on your current browser!");
}
function success(position) {
    var lat = position.coords.latitude;
    var long = position.coords.longitude;
    var city = position.coords.locality;
    var myLatlng = new google.maps.LatLng(lat, long);
    var myOptions = {
        center: myLatlng,
        zoom: 12,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

    var marker = new google.maps.Marker({
        position: myLatlng,
        title: "lat: " + lat + " long: " + long
    });

    marker.setMap(map);
    var infowindow = new google.maps.InfoWindow({ content: "<b>User Address</b><br/> Latitude:" + lat + "<br /> Longitude:" + long + "" });

    document.getElementById("<%= latt.ClientID %>").value = position.coords.latitude;
    document.getElementById("<%= lng.ClientID %>").value = position.coords.longitude;

    var div = document.getElementById('map_canvas');
    div.style.visibility = 'hidden';

    infowindow.open(map, marker);
}

mastermind
  • 67
  • 9
  • 1
    Geolocation isn't 100% accurate. The browser basically just uses IP adress, nearby wifi towers, and whatever else it can find, to try and geolocate the user. If the browser vendor has a sucky database, like Microsoft has, it's less accurate, or if you live way out in the bush, it's also less accurate, it's not like the browser just magically knows where you are ? – adeneo Dec 09 '15 at 06:31
  • I think it default browser supported. and Geolocation isn't 100% accurate. – HoangHieu Dec 09 '15 at 06:32
  • So what i have to use for insert person current Latitude and Longitude or location area name. @adeneo – mastermind Dec 09 '15 at 06:35
  • I hosted in public IP but crome is giving less latitude values and firefox giving big values. @HoangHieu – mastermind Dec 09 '15 at 06:37
  • Is there any concept find by IP address which will give accurate result. @adeneo – mastermind Dec 09 '15 at 06:43
  • There are companies offering access to large datasets of IP adresses, some even for free, like Maxmind, but it's not neccessarely more accurate than built in browser Geolocation, for instance one can assume Google has some pretty kickass datasets to geolocate users as well. – adeneo Dec 09 '15 at 06:51
  • I got another answer using 'GPS' location but i dont know will give little accurate or not, totally confuse go with above or i have to go with using Maxmind, please suggest. @adeneo – mastermind Dec 09 '15 at 07:09
  • The browser doesn't generally have access to GPS, unless it's running on a phone with GPS etc. Maybe this is useful -> http://stackoverflow.com/questions/4213410/how-does-html5-geolocation-work – adeneo Dec 09 '15 at 07:12
  • Then i have to use GPS sensing for the W3C Geolocation API. It might also be nice to have a feature for desktop computers where the location can be manually specified in browser settings, this would also be compatible with the current spec. @adeneo – mastermind Dec 09 '15 at 07:24

0 Answers0