简体   繁体   中英

How to get my current Location on my laptop - Java program

As Google latitude is no more.

I am writing a java program that get users current location on laptop computer. IP address does not return accurate place and Currently built-in GPS receiver are not common in laptops. I want to use my Android smart phone to send/sync user's current location to my java based program in laptop.

How would I do this via Bluetooth.

If you have any other ideas to get current location of the user then please also share.

[edited]

There is not an API for location within Google+. You can use the Google Maps Places API to get information of interest located close to a user. Before you can make API queries to the Google Maps Places API, you will need geolocation data (latitude and longitude) to make your queries.

For getting GPS data from the user's laptop, there are a number of approaches, however, I personally prefer to use a location database and perform lookups on the user's IP. The GeoLite databases from Maxmind are really easy to use: you get the user's IP address and then query the database for the location (specificity will vary based on the database used) and the location data will include anything you need for mapping purposes. This stack overflow question on geolocation includes a link to some example code that should get you bootstrapped.

You may also want to consider the geolocation API for modern browsers if you're using a web integration on the desktop.

Once you have lat/long coordinates, you can get location data using the Places API by passing in the coordinates to Place search APIs .

If you want to get location data from Android , you should use a location provider to set up location status updates. The Android documentation does a better job explaining the steps than I can here.

To transmit the data to your computer, you can use bluetooth .

There is one other way to achieve it using java only.

You can use selenium+PhantomJS to hit " https://mycurrentlocation.net/ ". This website by default will load you current location and you can read the data on this website using Selenium API.

PhantomJS is an invisible browser, it can open any website in invisible mode and read data from the same.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM