用Java获取用户当前的经度和纬度(Get user's current latitude and longitude in Java)

系统教程 行业动态 更新时间:2024-06-14 16:59:47
用Java获取用户当前的经度和纬度(Get user's current latitude and longitude in Java)

我在这里看到了很多关于Java的问题,但我看到的每一个问题似乎都是以Android为中心的:我需要一种方法来获取用户当前的经纬度来自他们的电话,而不是移动设备。 我知道这在C#中是可行的,但我不确定如何在Java中完成它。 我之前使用过Google Maps的restful API:但是,它想要一个地址作为输入,我只想获得用户当前的lat / lon,我觉得这比拨打Google更简单。 任何帮助将不胜感激。

I see this question asked a lot here for Java, but every single one I see seems to be Android-centered: I need a way of getting the user's current latitude and longitude when they call is coming from a computer, not a mobile device. I know that this is doable in C#, but I'm not sure how exactly to do it in Java. I've used Google Maps' restful API before: however, it wants an address as input, and I just want to get the user's current lat/lon, which I feel is simpler than making a call to Google. Any help would be greatly appreciated.

最满意答案

Java目前不提供通用的独立于平台的API来获取位置。 但是,可能存在特定于平台的方式。

台式机上的大多数实现都将通过IP地址进行地理定位; 您可以使用Java提供的这些服务( 在Java中获取地理位置的最佳方式 )。 但是,如果操作系统提供更通用的API,则可以利用任何GPS硬件。

对于Mac OS, https://superuser.com/questions/346302/is-there-a-way-to-access-os-x-location-services-from-the-command-line

这里有Gnome提供的库的详细信息,以及KDE支持计划的编写。

Java doesn't currently provide a general platform-independent API to get location. However, there may be platform-specific ways.

Most implementations on a desktop machine will geolocate via IP address; you can use these services from Java (Best way to get geo-location in Java). However, if operating systems provide a more general API, it can take advantage of any GPS hardware.

For Mac OS, https://superuser.com/questions/346302/is-there-a-way-to-access-os-x-location-services-from-the-command-line

There's detail here of a Gnome-provided library, and also a write-up of plans for support in KDE.

更多推荐

本文发布于:2023-04-17 09:15:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/6f889a9a669c14f96d0aee0034a81869.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:经度   纬度   用户   Java   longitude

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!