Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get user's home, work and starred locations like Google Inbox does

When in Google Inbox you go to snooze a message and select 'Pick place' it shows a list with your home and work address (from Google Now) populated as well as starred locations from your Google Maps profile. Other Google apps, like Keep also provide similar functionality.

I would like to implement this in my app but couldn't find the right API that exposes that information. Is that something that Google doesn't expose to 3rd parties (I guess there's room for abuse there)?

If not, how can this be implemented? What API has the data?

enter image description here

like image 723
Krzysztof Kozmic Avatar asked Sep 06 '15 23:09

Krzysztof Kozmic


People also ask

How do I find starred locations?

Starred items are in a list you can revisit inside the Maps application. To get to all your saved places, quickly, touch the slide menu (the three horizontal “hamburger” lines on the upper left) and select Your places. You'll then see the complete list – touch a spot you want to see; it will be on the map.

Does Gmail have location services?

Go to the "Location History" section of your Google Account. Choose whether your account or your devices can report Location History to Google. Your account and all devices: At the top, turn Location History on or off.

Does Google always know my location?

Google only receives Location History for each device where you are signed in and you have Location Reporting turned on. You can change the Location Reporting setting for each device where you're signed in, and limit which devices provide location data to be included in Location History.


2 Answers

Google Now utilizes analytics on your location data (on any and all devices signed into Google + location services enabled in your Google Account settings) to determine your home and work locations, unless you specifically set them.

The storage / retrieval of this data is not explicitly referenced anywhere that I have found in official Google documentation, but the schema in Google Now for this data is available here: Google Schema - Person

For any given person entity, a homeLocation and workLocation property exists with that data.

Alternatively (or in addition to), using Google's Plus Platform / Google Identity Platform, if you have an authenticated user, you can make an API call as described here (with examples) to get any of the specified fields for the current user (including currentLocation, organizations (including work) with addresses, if the user provided them).

A previous SO question that references using oAuth and raw Google Maps feed urls to pull the data exists, but the accepted answer is somewhat unclear and when I followed the links and attempted authenticated to test it out, I received 404 errors from all of them: Access locations in My Places of a particular account through Google Maps API

Also as in a Google Product Forums post here several years ago, a previous version of the Google Maps Data API allowed access to My Places, which is quintessentially exactly what you need, but it was deprecated and removed in 2013.

Finally, and this is the best approach in my opinion, and may be what Google uses (if it isn't declared to be Google Now), which is the Google Contacts API. A user exists in their own contact list, and the extensive API for Google Contacts allows you to get/set addresses with standard labels such as home or work for the user.

This is all detailed here: Google Contact Services - App Scripts

like image 127
Tyler Durden Avatar answered Oct 21 '22 18:10

Tyler Durden


Here is API for getting user's addresses

https://developers.google.com/android/reference/com/google/android/gms/identity/intents/Address

mGoogleApiClient = new GoogleApiClient.Builder(this)         .addApi(Address.API, new Address.AddressOptions())         .build(); mGoogleApiClient.connect(); ... Address.requestUserAddress(mGoogleApiClient, UserAddressRequest.newBuilder().build(), REQUEST_CODE);   @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {     ...     UserAddress address = UserAddress.fromIntent(data); } 

In dependencies

compile 'com.google.android.gms:play-services-identity:7.8.0' 

There is no Home or Work addresses here, and I don't understand what kind of addresses it uses. But it seems that all user's addresses should be here.

like image 36
Stas Parshin Avatar answered Oct 21 '22 20:10

Stas Parshin