Retrieving and plotting Places Search results on the map can get very expensive, especially if you're making repeated, overlapping calls to Nearby Search or Text Search to cover the map extent. Further, if you are trying to minimize call volume by caching response data, keep in mind you are subject to Google Maps Terms of Service (ToS). To optimize this workflow, we recommend the following approach:
- Save the place_id and lat/lng for each place from the Places API Search response during the initial call (see Places Search Library for more information). Google Maps ToS permits the following:
- place_id can be cached indefinitely
- lat/lng can be cached for up to 30 days
In this way, you only incur charges for the more expensive Places Search API at time of the initial request. Subsequent requests for lat/lng refreshes are made to the Geocoding Service, which is priced much lower than Places Search services.
Note: The only fields you are allowed to cache from the API responses are place_id and lat/lng. Caching other information such as business names, address, contact numbers, ratings, etc is not allowed per Terms of Service. With lat/lng alone, you have what you need to plot and visualize point data on the map and you can use place_id in an Info Window or on mouse hover as an identifier. Inside the Info Window, add a link to fetch additional information from Place Details using the place_id as the input.