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.
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.
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.
Related
Background
I work on an app that among other things, allows to contact with businesses found via Nearby-search, navigate to them, visit their websites...
Once the user performs any action on a single business, it's supposed to be added to the recents-list, allowing the user to do it again, or see the information about the business again.
If the user called some business, next time he visits the recents-list, it should be shown there as a list-item, along with the name, phone number, etc...
Same goes if it was navigated to.
The problem
I've noticed in the terms a very big limitation of caching, saying that only the place-ID is allowed to be store permenantly, and the basic geographic-coordinate (lat-lng) can be stored for 30 days.
Weird thing is that it says it's ok to store only place-ID and coordinate, but I couldn't find what's the use of these if there is no mapping and context whatsover with them. And of course if you add context, you actually do store more information. For example, if you've called the place and showed the name, you already know both, so both should be mapped to the place-ID...
Links:
https://cloud.google.com/maps-platform/terms/maps-service-terms#5.-places-api
Caching. Customer can temporarily cache latitude (lat) and longitude
(lng) values from the Places API for up to 30 consecutive calendar
days, after which Customer must delete the cached latitude and
longitude values. Customer can cache Places API Place ID (place_id)
values
https://cloud.google.com/maps-platform/terms/#3.-license
No Caching. Customer will not cache Google Maps Content except as
expressly permitted under the Maps Service Specific Terms.
https://developers.google.com/places/web-service/policies#pre-fetching,-caching,-or-storage-of-content
Applications using the Places API are bound by the Google Maps
Platform Terms of Service. Section 3.2.3(a) and (b) of the terms
states that you must not pre-fetch, index, store, or cache any Content
except under the limited conditions stated in the terms.
Note that the place ID, used to uniquely identify a place, is exempt
from the caching restriction. You can therefore store place ID values
indefinitely. The place ID is returned in the place_id field in Places
API responses.
What I've found
Sadly I couldn't find more information about this.
What I was told by someone is that caching should be fine for 24 hours as a part of "fair-use" to avoid re-queries of things that you already got, similar to how web browsers handle queries. This can help in case the user wishes to see information he already got just a few seconds ago, for example.
I was also told that if it's local on the user's own device, it should also be fine, as it's not published outside, and as the user could have saved the information anyway, manually.
For each of those claims, I couldn't find a reference.
This is very important here, as there has to be some mapping between the items on the "recents" list of the app and the actual place. For example, if it was a phone call, it has to at least have place-id (of the place) and the phone number (of the call). But it should also show the name of the place, as the user just showed this information and expect to see it there too, instead of just a phone number.
The questions
Weird thing is that it says it's ok to store only place-ID and coordinate, but what's the use of these if there is no mapping whatsover with them? What could I do with this exactly?
What is the fair-use of caching in this case?
Is it true that caching is ok in general for 24 hours, for all APIs ?
Can I also store in storage if it's very relevant as the user did something related to the query (dialed the phone number of the place, so should be possible to see this information right on the list, with other places)? I mean to store basic, relevant information I got from Google Places, for each recent-list-item ? Maybe I could set the basic information with an expired-date, while letting the place-ID stay, and when it's expired, only then to re-query?
Otherwise, it would mean the app will need to re-query all places each time the list is shown, to get a mapping between phone numbers and each place's information, and could easily cost a lot of money.
I want to put a link to a simple google search in my app. So if I search myself this is the link...
https://www.google.co.uk/maps/search/dog+groomer+near+me/#53.0725236,0.0423795,11.44z
It obviously has my coordinates in it. Is there a way for me to change it to a generic link so it automatically uses the users location?
You will want to use Android's location manager. This will allow you to get the user's coordinates (as long as they have location enabled on their phone.)
https://developer.android.com/guide/topics/location/#location
https://developer.android.com/guide/topics/location/strategies
It is up to you what you do with this. You can do a quick string replace and insert the user's coordinates inside the url. Or you could even include the google maps component into your app and have the results show up right in your app.
I was wondering if anyone has been working with this facebook-events-by-location library, because I've tried it myself and came across 2 potential problems:
The result list is too short (only about 20 items)
Some of the events are from another country (Germany) and have nothing to do with being nearby the provided location
What would you suggest that I obtain more events, and more importantly, ones that are in the nearby location?
Is there any other library like this one, or maybe there is a simpler way to directly use the Facebook Graph API and obtain more events by location?
Extra: do you need to some sort of premium (paid) account for the Facebook Graph API in order to get more results?
You can only search for Places by location, and then get the Events of those Places. That´s what the package actually does, if you take a look at the source or the Readme. The limit for Places is set to 100, and if there are only 20 Events in those 100 Places, you will not get more.
There is no API to get events by location, that package only a workaround. Also, there is no premium/paid account for the Graph API, it is just not possible (directly).
We are developing an android application and we are able to find out the users location using the Geocoder class.
Now after getting the location of the user we want to display some content which is specific to that area / locality. Our contents are grouped based upon the sub admin area, which we are getting using getSubAdminArea() of the Address class.
Now we are able to know the sub admin area, name of the user. But we are concerned that the sub admin area name entries which we will have in our table, may not match to that returned by google. In this case we won't be able to achieve our functionality.
So my question is, "is there any way by which we can get all the sub admin area's for a country using google map. So that we can populate those and there will be no chances of any mismatch. Basically we are trying to get all sub admin area / districts present in India.
As far as I know a data-set of all the sub admin areas for India (or any country for that matter) used within Google maps are not available publicly. However, there's a way you can get those for specific addresses that you would want to use.
This is a rather lengthy process so its totally your choice if you want to go through with it.
1) Make an individual Geocoding request for all the addresses. For example: https://maps.googleapis.com/maps/api/geocode/json?address=TajMahal+Agra
2) You will get all the admin area levels and sub localities that Google maps has for each location.
3) Check with your database and you should be good to go.
Useful links:
These are address types and components within gmaps.
This the FAQ for geocoder.
Docs for geocoding API just in case.
I was wondering how I can channel or simulate Google Maps just in the sense of a user types in a location in text, such as a restaurant name and a city name. Then Google suggests 5 or so places they have indexed, and presumably they know the GPS coordinates because Google then puts them on a map. I want to be able to use that feature- not the map, just getting the location.
My goal is for a user to type in a query, 5 options or so to be shown, and if they user chooses one of them, then the GPS coordinates, or a location object, is saved representing that place.
Ideally I could just send the query to Google and steal the results back to my app. Obviously building my own database of locations and an algorithm to suggest them is out of the question.
Thanks for the help and advice in advanced!
Note 1: To clarify, this does NOT involve the current position of the user/device.
Note 2: I looked at the Google Maps add-on API, but it looks like that is for a visual map, not the querying a location part. You are already supposed to know your location, and it will map it.
Use geocoder.getFromLocationName, you get back a list of Address objects, in those objects you will find all the information you need about the location.
To test this on the simulator you need an image with the Google APIs included. In a device should be fine if you have the market installed.