Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
247 views
in Technique[技术] by (71.8m points)

Google map places service returns both id and place_id for each place. Can I use the id to identify the place?

The Google places service nearbySearch request returns places with both ids and place_ids. Can I use the id field to identify a place? Old posts say that the id field is depreciated, and that I should use the place_id, but I can't find that information in the current documentation.

The reason I'm asking this is the place_id is something that changes from time to time (such as when a restaurant's address changes), so it's not ideal for me to use. I'm looking for a permanent id to identify a restaurant.

Can I use the id field to do this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The "id" field in Places API result has already been deprecated 4 years ago. In replacement, you'll need to use the "place_id" field moving forward which is the textual identifier that uniquely identifies a place. More info in this doc

This has also been answered in Google's Public Issue Tracker here: https://issuetracker.google.com/issues/134893143

Although the place_id is the unique identifier of a place and is recommended to use, it may change due to certain updates as per this doc. One strategy is to store the original request that returned each place ID. If a place ID becomes invalid, you can re-issue that request to get fresh results.

As of now, the place_id field would be the most recommended unique reference to a specific place.

Hope this helps!

Edit: Below is the deprecation notice that could once be found in the documentation.

Note: The id and reference fields are deprecated as of June 24, 2014. They are replaced by the new place ID, a unique identifier that can be used to compare places and to retrieve information about a place. The Places API currently returns a place_id in all responses, and accepts a placeid in the Place Details and Place Delete requests. Soon after June 24, 2015, the API will stop returning the id and reference fields in responses. Some time later, the API will no longer accept the reference in requests. We recommend that you update your code to use the new place ID instead of id and reference as soon as possible.

They do still return the ID field for some reason, but you should definitely use the place id instead.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...