4

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]

user584910
  • 525
  • 2
  • 8
  • 17

2 Answers2

1

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.

BullyWiiPlaza
  • 17,329
  • 10
  • 113
  • 185
class
  • 8,621
  • 29
  • 30
  • Sorry, I have edited and corrected my question accordingly. Please guide me, using Google Maps places API how can I get my current location automatically my java application in laptop. – user584910 Feb 27 '14 at 05:53
  • Thanks again. IP based approach don't get you exact location. I want to use andriod mobile phone GPS sensor to pass lat/long to my java app installed on laptop and then I will query GOOGLE Places to get place name against lat/long. Please someone guide me on how would I get lat/long on my laptop from smart phone GPS receiver? – user584910 Feb 28 '14 at 07:08
  • These APIs need internet connectivity. Is there any way to get the places db offline, so that I could be able to query them offline against lat/long. – user584910 Mar 01 '14 at 11:55
  • Added notes. I'm not aware of any ways to get or use the location / places databases offline and perform proximity based searches on them. – class Mar 03 '14 at 17:02
1

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.