Is it possible to detect a mobile browser's GPS location? [duplicate]

烈酒焚心 提交于 2019-12-18 12:27:37

问题


I am making a web site targeted at mobile phones and would like to get the user's current GPS latitude/longitude when they visit my default page so I can show them results in their area. Is this possible using ASP.NET?

See Also

Get position data from mobile browser


回答1:


There are services that will give you a location based on IP address. It won't be as precise as the GPS data but without having an application installed on the phone it may be as close as you are going to get.




回答2:


Yes, you can do it with JavaScript and submit results back to server:

        function onPositionUpdate(position)
        {
            var lat = position.coords.latitude;
            var lng = position.coords.longitude;
            alert("Current position: " + lat + " " + lng);
        }

        if(navigator.geolocation)
            navigator.geolocation.getCurrentPosition(onPositionUpdate);
        else
            alert("navigator.geolocation is not available");



回答3:


Currently, GeoLocation API is highly available in modern smartphones.

See my answer to related question How to Get GPS location from the web browser. The solution is pure-javascript so it is server-technology-independent.




回答4:


You'd have to get security permission to access the appropriate GPS API. As long as you know the API, you'll be able to obtain the appropriate data, but it'll depend on the OS. I know it is accessible via Python as PyS60 for Nokia phones.




回答5:


You're not going to have much luck at the moment, but this is something that should be possible within a few years. The W3C have published a Geolocation API Draft, and this has been implemented into a jailbreak iPhone app called Locatable, but support is going to be so few and far between it's not worth the implementation time!



来源:https://stackoverflow.com/questions/762141/is-it-possible-to-detect-a-mobile-browsers-gps-location

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!