开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜