Cache strategy for google places api nearby result. - api

Im trying to figure out how i would go about caching the result i get back from a nearby search. So i can get upto 60 places based upon my current long lat position.
So im thinking that if user1 ask google for nearby places within a radius of 1km from position long: xxx lat: xxx. And i get a result back with places. And then user2 is asking for nearby places 500m away from user1. Then i would like to be able to use the cached data that user1 already fetched from google.
Any suggestion on how i would go about implement this kind of functionality?
Or should i just cache each place by their long,lat and implement my own geosearch?

I'm not aware of any built in google maps library that allows you to do radius search without calling the server. Best bet would be to make your own geosearch on the fetched points or use an open source library to help you.
If you do use cached data but remember that there's no guarantee how much of the 60 places fetched in a 1km radius are also within the 500m radius. If you did another query for 60 places within a 500m radius you'd get more accurate information.
Disclaimer: Google has certain rules in place about caching data. 10.5 d) https://developers.google.com/maps/terms#section_10

Related

Get different results every time when call google places API based on lat long and radius

I'm getting different results every time when I call google places API. I'm using https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=1500&keyword=cruise&key=YOUR_API_KEY API and put location lat & long & radius dynamically and call multiple times back to back. So I get different output every time. It gives me Zero results or 2-3 places on same API.
Check below images.
You are getting different results because Nearby Search responses may be missing a few results occasionally; this is intended behavior for the API due to the distributed and constantly evolving nature of Google Maps.
Check out this issue reported in Google's Issue Tracker for reference https://issuetracker.google.com/issues/119250563
Hope this helps!

How do I search this? Possible to access more than 100 JSON api search results if I pay for it?

How to search this?
I want to be able to:
1. create a search engine
2. programatically search it thorugh an API (python, or other)
3. paginate through the results (all of them, if I chose)
4. store URL's or results that I want.
Is this even possible with Google Custom Search Engine?
I enabled billing, my CC is up to date with Google, I do steps 1..3 above.
On a search, I will get back 4,000 results for example, but I can only access 10 at a time with the API, none more, and when I reach 100 results I am shut off.
I want to be able to process 1000 results if I wish.
Before you reply, do you personally have working code that goes beyond the 100 limit?
If so, would be very much interested in speaking, learning how you did it.
I am using Python at the moment, but it could be any language.
--
I tried using the &start=100, 200, and so on to paginate through, but this does not work.
I tried getting 100 results in a python script, ending the program, calling it again setting start=100 (after the first set returned), and nothing happened.
I want to be able to use the Google Custom Search API, pay Google for a monthly subscription but have not found that this is possible.
For any given search, I want to decide how many results to process, could be 1K, could be 20K, I simply need/want access to the full result set, but I do not, have not seemed to find a way to do this.
The API allows only a max result depth of 100. See https://developers.google.com/custom-search/v1/cse/list

How can I save or get data about places near me without breaking policies

This is more of a general programming question.
I'm trying to create an app, think of it as a Yelp clone. I have most of it working but I'm missing one important feature. The data of the places around me. For now I'm only focused on food, so I'd like it if I search something like "Pizza", it'd show me all the pizza joints near me.
I was originally planning to use Google Places API. However if you havent heard, they're changing their pricing and lowering the free tier and upping the cost by a huge margin.
There's also the problem of saving the data. One workaround I saw a user suggest was to just keep using Google's API, but every time you make the query, store the data in your own DB as well (I only need address and name and latitude and longitude) so eventually, you'd have what you need in a sense. However I also want to have something like a simple rating system for each place like Yelp, but Google (and all other places like MapBox, Here Maps, etc) states something along the lines of "info from their API should not be stored or cached for more than 24hrs" but it's very broad and not specific.
So what I was planning to do was, call the Google API, grab the 3 info I need (Address, Name, Lat/Lng), add more fields to store the rating, likes, whatever else the user will add. Then store it in my database, but that doesn't seem like a solution now.
So does anyone have any ideas or advice? Or know of a service where I can get the details of all the food places? And if possible, can anyone confirm that storing the Name, Address, Lat&Lng is a violation of their policy since in my eyes, it's public data, but something like the rating that Google provides, or the pictures that Google provides, now that's Google property.
For obtaining places you can use OpenStreetMap, e.g. using Overpass API. Since larger traffic can be expected you should run your own database(s) instead of using the public APIs.
However OSM doesn't contain ratings. So you have to combine this data with some other publicly available rating system.

Is it possible that I already exceeded the limit of query for Google Maps Static in just an hour of testing?

I just started playing with the Google Map API for Static Images, and in just an hour it has appeared this image:
http://www.coon.it/drop/limit.png
Is that normal?
My page need 6 static image, that means that I call it, like 170 times?
I don't think it's possible since the pictures are always the same and the documentation says that if i call the same image it doesn't count.
What can i do?
Thank you
Although there is an absolute limit on the number of images, that limit may be calculated over a shorter period than 24 hours. 2400/day could be interpreted as 100/hour, so you can't use all 2400 in one go [I can't remember what the limit is for Static Maps, but you get the idea].
With most Google services there is also a rate limit, and it's possible that fetching six images almost simultaneously breaks the rate limit. Rate limits vary depending on server load, but spacing requests out to 200ms should be ok.
Or it may look like an automated image-fetcher (especially if you have run it 30 times in the last hour). Google don't like automated crawlers either.
What should it display? With me it just displays a landscape with a row of trees(what i gues is what you want to see?).

limit address search by distance

I recently joined a team working on an application that maintains listings with addresses. The user searches, and includes their zipcode, and the application displays the distance to each listing. Currently we use the Google Maps API for this. Reading through questions here on StackOverflow seem to suggest that this is the best way of doing things:
php/mysql zip code proximity search
Search engine by distance
However, while reading through the API documentation, this seems to be expressly forbidden unless we also show a map for each result (and possibly also for each result we filter out, depending on how you read the following statement):
Use of the Distance Matrix API must relate to the display of information on a Google Map; for example, to determine origin-destination pairs that fall within a specific driving time from one another, before requesting and displaying those destinations on a map. Use of the service in an application that doesn't display a Google map is prohibited.
( https://developers.google.com/maps/documentation/distancematrix/ )
What's the best way to accomplish this without running afoul of any API terms?
do you consider the Geo::PostalCode module (perl)? It uses maxmind database to calculate distances between locations (and there is bind in different languages).