How are request counted in Google Location API (Android) - android

Sorry if this question is obvious, I haven´t found a clear answer in other posts.
I am creating an Android app and I am planning to use the Google API to get a more accurate location. My question is about the request limit of the API(2500 request per day if you don´t pay): I guess that every time I call getLastLocation() counts as a request, but in my app I want to update the location periodically using LocationRequest methods like setInterval()
Thank you in advance.

taking geo-location and plotting it on Map are two different things.
To get geo-location there in no such limit as of now! From Android version O, there will be such limit for background location limit refer this URL
to Plot the coordinates on map these is such limit as mentioned here
so your can take any amount of location data,but plotting it on Map is limited i.e 2500/day.

Related

Is there a way to get a list of places based on a specific location in Android Development?

I've been looking at the Places API from Google for this, but I don't know if this is the right direction to take. The project revolves around finding a list of places based on a specific location, other than the current location (for instance, what kind of restaurants are around your friend's house (based on longitude and latitude)). Most of what I've seen with the Places API involves using the user's current location. Is there a way to pass in a predetermined location? Or can I fool it into thinking that location is my current location?
I think still places is the best option for you, you have to really understand the api to get what you need from it. Look at how could you send a request to the places api with a given location (long, ltd) and it will return nearby places.
https://developers.google.com/maps/documentation/places/web-service/search-find-place#locationbias

Android gps coordinates location updates

I want to develop an app that receive from the server coordinates every 10 seconds and update the location on the map. How to do it?
On how to obtain the GPS coordinates look here:
https://developer.android.com/training/location/receive-location-updates.html
You can set the update interval to 10 seconds in the LocationRequest object.
For integrating a map in your app and setting markers on it you can look here:
https://developers.google.com/maps/documentation/android-api/start (for google maps)
or use some alternative provider for maps data like OpenStreetMap (see https://github.com/osmdroid/osmdroid).
Edit: Maybe you should start with a tutorial like this one: http://code.tutsplus.com/tutorials/getting-started-with-google-maps-for-android-basics--cms-24635

Google maps sharing location

I want to make a android app using google maps.In this app I want to share my location to my friend like a request, Once he accepted my request he will get the route map to my location (previously I shared) and also I want to see his moving path towards my location. Can any one please suggest me how is possible to sharing locations.
I think the best way to control that sharing is using socket.IO
on the device you catch your position then emit your position to the server and on the server side you emit to other devices.
Hope helped you
For sharing locations and showing it on map, you need to do it in following steps
Read your location using android APIs.
Once he accepts your request, read his location and share it to your profile through some API to server & keep on updating location on every changed distance delta or at some time interval and share that too.
Now you have co ordinates of both locations. Use them to fill data to Google Maps API and load map in one of your activity. Whenever you will receive updated location of your friend from your server, update the map and draw path between them using google maps api.
For showing map to your location # your friends side, same thing needs to be done. If your location will also change then you will have to provide your updated location to server timely as mentioned in step 2
What if you send a geo: link to your friend? Like geo:62.0,-7.0 ? That should give the receiver a choice between all his geo-capable apps. Google Maps, OsmAnd, maybe some weather service...

Why do I get Google Geocoding API error: over query limit?

I am working on an Android app that displays a map, and when the user clicks on it, it takes the Lat/Lng and send them to my Rails server, that does the reverse_geocoding and store the address and the coordinates in the database. Then, the user can see the map with all the places around his location displayed.
I just added the functionality to create the place via the app yesterday, before that I used activeadmin directly in Rails, and everything was working fine. But yesterday, when testing my app, I suddenly got the Google API error :
Google Geocoding API error: over query limit
How is that possible ? I know there is a limit of 2500 request/day but I am far from that number, I did maybe 50 creations yesterday, in a 2 hours period.
It works again when I wait like 30 minutes or so...
For the reverse geocoding I am using Geocoder. Is that possible that Location.near does a request to Google API each time ? Normally it does not request Google servers when Lat/Lng are provided, but it checks only in the database, right ?
Or can it be my app that sends this kind of request to Google servers each time I display the map ?
I am a bit lost here...
Thanks !
Geocoding services also limit based on queries per second as well, which may be the reason for that message.
Geocoder does makes an API call every time you call Location.near("foo") (in order to get the lat/lon of the foo). In combination with geocoding your models, you may be hitting the rate limit.
You may want to try adding some retry logic when the query limit exception is called, or getting the lat/long from your Android app and pass that directly to the query, avoiding the .near geolocation.

Creating a random lat/long coordinate that is positioned in a physically reachable location

I have an application that generates some number of tokens around the current location of the user using a certain distance radius. The user will then have to run to some of those locations. The problem is that some tokens can be created in a lake,forest,ocean, or some other physically unreachable location. As a quick fix I just generate extra tokens and increase the proximity distance that determines if a user reached a certain location. I now want to improve this so that each token is located at a reachable location.
The only solution I have been able to come up with is using the Google Directions API to determine a path from the user to the token and use the last coordinate in the polyline as the new reachable location of the token. My problem with this is that I potentially have to post up to 30 requests to the Directions service simultaneously and I am worried that I might hit the query rate limit. I have not found anything definite about query rate limit.
So my question is whether anyone knows of a better solution or can give any input on the Directions query rate limit? Waiting 1 second between each request and forcing the user to wait up to 30 seconds is not a reasonable solution. Thanks.
UPDATE
Using the solution that I described in the question does produces an OVER_QUERY_LIMIT, even if I wait 1 second between each request. Other then that the logic was sound and tokens that got a request thru were appearing in walk reachable locations.
You can calculate the distance between two lat/lon with Location.distanceBetween(). This is a static convenience API call. There's no limit on number of calulations.
Usage limits
Use of the Google Directions API is subject to a query limit of 2,500 directions requests per day. Individual directions requests may contain up to 8 intermediate waypoints in the request.
Google Maps Premier customers may query up to 100,000 directions requests per day, with up to 23 waypoints allowed in each request.
You might want to take a look into the Maps premier customer so you don't hit the limit too fast. If your app becomes popular I bet you can get an higher limit.
One way would be to see if you can see the elevation to see if it's a cliff or not. However just seeing if it's a lake or not seems to be quite hard. Might be some kind of gps lookup service out there except Google Maps.
If you just want to know the distance between locations just use Location.distanceTo() or static distanceBetween()
Getting the info if it's a road or not is another question.
After some 8 hours I finally got something working. So using the fact that each request can have up to 8 waypoints I can technically ask directions to 9 locations in one request. Here's what I am doing now:
Generate 9 random locations at a time. Pass the locations to my DirectionsComputer which returns the polyline path that goes through all 9 coordinates as a list of coordinates. Then I pick 9 location from the path and set them as the locations of my tokens. Now all my tokens are semi-randomly generated, always appear on a road, and I only need to do 4 consecutive requests to generate 36 tokens.
There are some cases where a few tokens are bunched together. For example, the coordinates which are originally located in the ocean get moved to the same beach. But for the most part, all my tests showed the tokens spread apart and I could tweak the rest.

Categories

Resources