0
var initialLocation;
        var siberia = new google.maps.LatLng(60, 105);
        var newyork = new google.maps.LatLng(40.69847032728747, -73.9514422416687);
        var browserSupportFlag = new Boolean(); // Try W3C Geolocation (Preferred)
        if (navigator.geolocation) {
            browserSupportFlag = true;
            navigator.geolocation.getCurrentPosition(function(position) {
                initialLocation = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); // THERES OUR LAT/LONG VALUES
                ajaxPost(initialLocation);
            },
            function() {
                handleNoGeolocation(browserSupportFlag);
            }); // Try Google Gears Geolocation
        } else if (google.gears) {
            browserSupportFlag = true;
            var geo = google.gears.factory.create('beta.geolocation');
            geo.getCurrentPosition(function(position) {
                initialLocation = new google.maps.LatLng(position.latitude, position.longitude); // THERES OUR LAT/LONG VALUES
                ajaxPost(initialLocation);
            },
            function() {
                handleNoGeoLocation(browserSupportFlag);
            }); // Browser doesn't support Geolocation
        } else {
            browserSupportFlag = false;
            handleNoGeolocation(browserSupportFlag);
        }
        function handleNoGeolocation(errorFlag) {
            if (errorFlag == true) {
                initialLocation = new google.maps.LatLng(geoip_latitude(), geoip_longitude()); // THERES OUR LAT/LONG VALUES
                ajaxPost(initialLocation);
                navigator.notification.alert('Geolocation service failed', // message
                'Geolocation Error!', // title
                'OK' // buttonName
                );
            } else {
                initialLocation = new google.maps.LatLng(geoip_latitude(), geoip_longitude()); // THERES OUR LAT/LONG VALUES
                ajaxPost(initialLocation);
                navigator.notification.alert("Your browser doesn't support geolocation. We've placed you in Siberia.", // message
                'Browser Error!', // title
                'OK' // buttonName
                );
            } // THERES OUR LAT/LONG VALUES
        }

This is code we use in our Sencha Touch application to get the users current position. Now, I tested this code using a 3G connection on my Droid HTC Eris, and it gave me a location 6 miles away from myself, which is fine, I can live with that, I could probably even live with a little bit more.

However, testing on an iPod Touch using Wifi, connecting to our in home router, it put us 147 miles from our current location. Now, this might make sense if our router here had some weird IP address or something like that (w/e this code actually uses to find location if it doesn't fall back to IP), but I testing geolocation straight from google from a laptop also hooked up to our wifi here and it puts us less than 1 mile from overhead.

What kind of situation could make this happen? Is this something we are just going to have to live with until geolocation further advances? If so, that's fine, I just want to know if there's something we could do to improve this. 147 miles away is a little crazy, considering every other source we've tried puts us within 10 max.

slandau
  • 23,528
  • 42
  • 122
  • 184

1 Answers1

0

The only thing I can think of is that google has some correction listings in it's own databases. What is probably happening is your ip is registered to a holdco which is 147 miles away from you. For example if whois my IP it is registered to a holding company which is about 50 miles away from me. Non-corrected databases (such as the ones you typically buy online) show me in that town. Google, whoever does not.

meteorainer
  • 913
  • 8
  • 21
  • That makes sense. So basically what your saying is, when I send my IP over to Google or something, or a corrected database, it'll give me the right location (as corrected as it can be), however if I'm using a geolocation framework from Sencha Touch, it might not be corrected - and just using the easy way out? – slandau Jun 30 '11 at 00:36
  • ya pretty much. we did a handheld GPS app at work a yr or 2 ago and that was the case for us. We got the actual GPS location from the handheld (which was a geocache type handheld) and still had to correct based on the local calibration stations. – meteorainer Jun 30 '11 at 01:55
  • Guess I'll wait for the geolocation libraries to all have built in correction :) Since this is all somewhat new that might be a while though, lol. Thanks for your help. – slandau Jun 30 '11 at 02:55