7

Google maps allows the possibility of saving favourite locations for ease of access later... see here.

In Android, where a location is required to be entered, it would be neat if there were an API to enable the user to choose from their already-saved favourite locations, e.g. via a picker dialog or something along those lines.

I can't find such an API... is there? The closest I've found is this and this, but these don't seem to allow picking from your stored locations.

drmrbrewer
  • 11,491
  • 21
  • 85
  • 181
  • 1
    Based on this [thread](https://groups.google.com/forum/?fromgroups#!msg/google-maps-api/hOmJjw90woM/RaXaOMXArgIJ), there is no API that can do what you want to achieve. So as of now I don't know if this is possible or not, but try to check this [SO question](http://stackoverflow.com/questions/11930287/access-locations-in-my-places-of-a-particular-account-through-google-maps-api), it might help you even in a slight way. – KENdi May 12 '16 at 10:16
  • What about something like the Address API: http://stackoverflow.com/a/33057472/4070848 -- So far as I can tell, the user can choose from their existing addresses (not sure where from, maybe contacts?). I've spent hours trying to get it working, but can't. After `Address.requestUserAddress()` it just returns an error code straight away to `onActivityResult()` and no picker and no actual results. – drmrbrewer May 14 '16 at 09:44

2 Answers2

0

There really isn't a way to do this, but you could create your own method to do it. You could have an ImageButton with a star (or anything that symbolizes 'save'). Use SharedPreferences to save the latitudes and longitudes that the users have entered, and then every time the application is loaded up, you could check to see if there are some values in the SharedPreferences. If there are, you could use a ListView to show all the saved locations, and then when one is clicked, return to the parent activity with the Location. Finally, use the Location to orient the map correctly.

AkashBhave
  • 749
  • 4
  • 12
  • Yeah, though I was hoping for an off the shelf solution (no point in re inventing the wheel when Google already did that). But if there isn't, looks like I'm going to have to roll my own. – drmrbrewer May 24 '16 at 22:30
  • OK, cool! Glad you found your solution! So my solution doesn't work :( – AkashBhave May 24 '16 at 22:43
  • It's not that it doesn't work, it's just that I'm was really asking for a way of accessing the user's (or rather, allowing the user to access their) stored google locations, rather than implementing my own bespoke solution only to find that google had already done it :-) – drmrbrewer May 26 '16 at 06:57
  • @drmrbrewer Any updates on this? Is there a way to track in our app similar to google's location history? Please guide. Thanks in advance – shakunthalaMK Jul 11 '19 at 17:52
0

Google/Android doesn't provide any public API to access the starred/frequent locations of a user and that data is only shared amongst the Google apps.

As this answer shows it might be possible to fetch location data via the Google Plus and Google Identity platform APIs

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).

Take a look at this link.

Community
  • 1
  • 1
Dominik Schmidt
  • 537
  • 1
  • 8
  • 22