是否可以检测移动浏览器的GPS位置? [重复]

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


This question already has an answer here:

这个问题在这里已有答案:

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?

我正在建立一个针对移动电话的网站,并希望在用户访问我的默认页面时获得用户当前的GPS纬度/经度,以便我可以在他们的区域显示结果。这可能使用ASP.NET吗?

See Also

Get position data from mobile browser

从移动浏览器获取位置数据

5 个解决方案

#1


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.

有些服务会根据IP地址为您提供位置。它不会像GPS数据那样精确,但如果没有在手机上安装应用程序,它可能会尽可能接近您。

#2


12  

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

是的,您可以使用JavaScript并将结果提交回服务器:

        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


1  

Currently, GeoLocation API is highly available in modern smartphones.

目前,GeoLocation API在现代智能手机中具有很高的可用性。

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.

请参阅我对相关问题的答案如何从Web浏览器获取GPS位置。解决方案是纯javascript,因此它与服务器技术无关。

#4


0  

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.

您必须获得访问相应GPS API的安全权限。只要您了解API,您就能够获得适当的数据,但这取决于操作系统。我知道它可以通过Python作为PyS60用于诺基亚手机。

#5


0  

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!

你现在不会有太多运气,但这应该可以在几年内实现。 W3C已经发布了Geolocation API草案,这已被实施到一个名为Locatable的越狱iPhone应用程序中,但支持将会很少,而且不值得实施时间!


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.itdaan.com/blog/2009/04/17/d121110ba596cb37088c6a6c6e43ce20.html



 
© 2014-2018 ITdaan.com 粤ICP备14056181号