Google places API: from CID to reference? - google-maps-api-3

My objective: populate a database with known business places in order to generate maps with those places. I insist on "known places", because my users will only search for the places that are in the database.
I don't want to recreate business places as markers on the map (so latitude and longitude is not enough to id a place), because the places are already available on Google Maps with interesting information (address, comments, ratings, pictures...).
The natural reference is to use the CID and store it in the database.
Now imagine the database is populate with places and their CID, and I want to generate maps with those places as click-able markers. When the user clicks on the marker, she access the business place's page, e.g. http://maps.google.com/maps/place?cid=998657413562662319. Great!
But how to generate those maps? I don't have the coordinates in the database (assumption). And I cannot use Google Places API (which would give me the coordinates), because it uses a different reference, to retrieve the location of the business so as to generate the maps.
Any ideas?
Thanks a lot!
To clarify: I want to use Google Maps API to generate a map with many business places of which I know the CID. It is comparable to "my maps" in Google. Only that I want to store the places in my database.
Potential solution: For each business in the database, store the name, CID, and coordinates. Write a script that uses Google Places to find businesses at specific coordinates. Loop through the response array (JSON/XML) until the response with the CID corresponding to the searched business is found. Store the Google Places reference into the database. Repeat this script for each newly added business. Cumbersome...

Is this what you are looking for?
http://maps.google.com/maps?cid=998657413562662319
It looks like your best option if you want more than one cid on a map is to use:
http://maps.google.com/maps?cid=998657413562662319&q=a&output=json

Related

Check if a railway track is near location

I've been looking into this for quite a bit, but couldn't find a solution. Is there a way to find out whether railway tracks are near a users position?
The APIs don't provide a places search like this (see Google Places supported types for this). One possibility would be to download the OpenStreetMap dataset for your region, import it in a database and extract the datasets Railways. Then you could pass the users position to your database (PostGIS) and check if there is a railways matching your filters.
Moreover there is the OpenRailwayMap, if you just need a possibility to do some visual identification of railway tracks. See OpenRailwayMap API site for further usage information.

Google geocode API results - storing the data

This is a question specifically for the Google Developer Relations team. I have read the Geocode API T&Cs and I am aware that I am not allowed to store data except by way of a temporary cache (e.g. for performance). Is this the end of the matter? I am developing a product which requires a search with results sorted by distance from a place, meaning that all my records need a lat/long. I was intending to use the Geocode API to get the lat/long when a user adds a record, and then adding that lat/long info to the record. We would then use the Haversine formula to calculate the relative distances and sort the results.
If I follow this approach, will I be in breach of the T&Cs? If so, is there another approach using the Geocode API which will allow me to hold onto lat/long data so that I can sort my results by distance, within the letter of the T&Cs?
For anyone else commenting, please observe the following restrictions: (1) we don't have a budget to buy a postcode-lat/long dataset; (2) we don't want to use a static dataset of our own, eg GeoNames, because we don't want to have to maintain data which is, effectively, public; (3) we have to support users who have javascript disabled.
To be absolutely clear, what I need here is to have the lat/long for all of my records in hand so that I can do effective searching and sorting by distance relative to another lat/long as provided, e.g. by a user searching.
Google Team, please respond to this message with contact details so we can speak.

api for retrieving object at a specific gps coordinate

I have been reading the google maps api and the openstreetmap api, but i cannot find if they offer the following functionality:
I need to find out if at a specific gps coordinate there is a building or a street.
Do you know of any api offering this?
Thanks.
I wonder how you could missed that if you already did look at the documentation.
Of course OpenStreetMap can do this. There is the main API (which is primarily for editing and not for bulk querying!) where you can retrieve all map data within a specified bounding box.
Example:
http://api.openstreetmap.org/api/0.6/map?bbox=13.76500,51.05600,13.76515,51.05615
This will return all objects between latitude 51.05600 and 51.05615 and longitude 13.76500 and 13.76515. For how to interpret the returned XML file read OSM XML in the OSM wiki.
In order to know if a specific object is a building, a street or something else you have to look at the tags. Buildings are usually tagged using the building key and can either be a single node, a way or (rarely) a relation. Streets are usually ways and are tagged using the highway key.

Using the Googlemaps Geocoder and Storing the Data

I am building an Events site in which the address of a given event will be stored to be used within a map on the page. Whilst viewing an Individual Events' page i would like to provide a list of similar events on side of the page. I would also like to rank this list by distance and display a small map with a marker on it for each item on the list.
I was thinking of Geocoding the Events address upon content input and then storing this data within the sites database. Doing this would allow me to calculate the distance of an event on the server and then provide an ordered list to display.
My question is this:
Would this violate the Googlemaps Terms of Service?
These terms:
"the geocoder for any purpose other than obtaining locations that will be displayed using the Google Maps APIs is a violation of the Terms of Service. You may use the HTTP geocoder to geocode addresses outside of your Google Maps API application so that they may be cached and later displayed using one of the Google Maps APIs, but locations obtained using the Geocoding Web Service may not be used by any other application, distributed by other means, or resold."
Suggest that storing the data is not a problem but i am unsure that the process of ordering the list by long lat would not result in a violation.
Any advice would be greatly appreciated.
As long as the map your refer to in your question is a Google Map and you are using the geocoded data to display features on a Google Map, you are fine. The client-side google.maps.Geocoderdev-guide is intended for dynamic requests that are based on real-time user interaction that drives a need to perform on-the-fly geocoding. But Google encourages you to consider using the Geocoding Web Servicedev-guide on the server-side, when you wish to pre-geocode static addresses or coordinates prior to using the response values on a Google Map. Storing those values is assumed.
It is common to perform some form of post-response/post-storage processing on those values, just like the ordering by distance that you describe, to fit whatever use case is needed to populate your map with the appropriate data. I understand you want to be careful to remain within the TOS, but what you describe sounds pretty standard.

Google Maps JavaScript API v3 Places Library Usage Limits

I have a site that associates Google Place information with users, and displays that information on a map. For instance, a user can search for a place (currently with the Places Library Autocomplete API) and bookmark this place for later retrieval.
As per the Google Maps TOS, I am only storing the Place ID and its reference in my database and am making client-side requests for the coordinate information of each place whenever I need to display them on a map.
I've recently encountered an issue where making more than 10 consecutive API requests for coordinate information (within a javascript loop) using the getDetails method on the service object returns an OVER_QUERY_LIMIT status code.
My question is this: if I am correct in assuming that storing the latitude and longitude of each place in my database violates Google's TOS, how can I programmatically retrieve the coordinate information for a number of places so that I can display these places on a map for a given user?
According to the terms - 10.1.3(b) -
(b) No Pre-Fetching, Caching, or Storage of Content. You must not pre-fetch, cache, or store any Content, except that you may store: (i) limited amounts of Content for the purpose of improving the performance of your Maps API Implementation if you do so temporarily, securely, and in a manner that does not permit use of the Content outside of the Service; and (ii) any content identifier or key that the Maps APIs Documentation specifically permits you to store. For example, you must not use the Content to create an independent database of "places" or other local listings information.
So if there are places getting queried a lot, you can temporarily store information on that place to increase performance.

Resources