我在这里看到了很多关于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.
更多推荐
发布评论