If using the Places library, a search returns a PlaceResult
object that has two properties that can help you:
id contains a unique identifier denoting this place. This identifier may not be used to retrieve information about this place, but can be used to consolidate data about this Place, and to verify the identity of a Place across separate searches. As ids can occasionally change, it's recommended that the stored id for a Place be compared with the id returned in later Details requests for the same Place, and updated if necessary.
reference contains a token that can be used to query the Details service in future. This token may differ from the reference used in the request to the Details service. It is recommended that stored references for Places be regularly updated. Although this token uniquely identifies the Place, the converse is not true: a Place may have many valid reference tokens.
Edit:
Note: The
id
andreference
fields are deprecated as of June 24, 2014. They are replaced by the new place ID, a unique identifier that can be used to reference specific places. The Places service in the Google Maps JavaScript API currently returns aplace_id
in all responses, and accepts aplaceId
in the Place Details request. Soon after June 24, 2015, the service will stop returning theid
andreference
fields in responses. Some time later, the service will no longer accept thereference
in requests. We recommend that you update your code to use the new place ID instead ofid
andreference
as soon as possible.