简体   繁体   中英

geolocation using html5

Hi i am using html5 geolocation to get user current location.it's working fine with all the desktop browsers except safari . it's also working with iphone and ipad ,all the android devices except samsung tablet . it's inter into error callback instead of successcallback. can i have some free javascript library which i can use as fallback for this device for usa users. i know maxmind library but it's response is not so much accurate.if any one have idea than please let me know about that. if u have any better idea to overcome this situation tan let me know . thanx

heres the javascript i used for my site which works on every browser i can find in the office.

if (navigator.geolocation) {
                    navigator.geolocation.getCurrentPosition(function (position) {
                        latitude = position.coords.latitude;
                        longitude = position.coords.longitude;
                        //call your function that responds to lat & long
                    }, // next function is the error callback
                        function (error) {
                            switch (error.code) {
                                case error.TIMEOUT:
                                    alert("Timeout");
                                    break;
                                case error.POSITION_UNAVAILABLE:

                                    alert("Position unavailable");
                                    break;
                                case error.PERMISSION_DENIED:

                                    alert("Permission denied");
                                    break;
                                case error.UNKNOWN_ERROR:

                                     alert("Unknown error");
                                    break;
                            }
                        }
                        );
                }

With the error checking in that code you should be able to diagnose what the error is from there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM