Google Places API place_id field length

2020-08-09 05:42发布

问题:

Google has marked the reference and id fields as deprecated as of June 24th 2014, and replaced it with a single place_id.

I've so far only seen place_id lengths of exactly 27 characters, but wonder if there is any documentation for this length? I have been unable to find this documented anywhere.

Obviously knowing the length of the place_id is significant for choosing an optimal database field, and therefore something I'd like to know.


From the Google Places API docs site:

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.

回答1:

There's no documentation on the specific length, but the max I have seen is length 255. This corresponds to address 488 Srinagarindra Rd., Suan Luang, Bangkok, 10250. You can check the place id here.

FYI the place id is:

ErwBNDg4IOC4luC4meC4mSDguKjguKPguLXguJnguITguKPguLTguJnguJfguKPguYwg4LmB4LiC4Lin4LiHIOC4quC4p-C4meC4q-C4peC4p-C4hyDguYDguILguJUg4Liq4Lin4LiZ4Lir4Lil4Lin4LiHIOC4geC4o-C4uOC4h-C5gOC4l-C4nuC4oeC4q-C4suC4meC4hOC4oyAxMDI1MCDguJvguKPguLDguYDguJfguKjguYTguJfguKI



回答2:

The longest I've seen so far is 315 characters. I'll update this if I find any longer.

FormattedAddress: KAV.76-78, Indofood Tower, Sudirman Plaza, Jl. Jend. Sudirman No.76-78, RT.3/RW.3, Kuningan, Setia Budi, Kecamatan Setiabudi, Kota Jakarta Selatan, Daerah Khusus Ibukota Jakarta 10250, Indonesia

PlaceId: EsIBS0FWLjc2LTc4LCBJbmRvZm9vZCBUb3dlciwgU3VkaXJtYW4gUGxhemEsIEpsLiBKZW5kLiBTdWRpcm1hbiBOby43Ni03OCwgUlQuMy9SVy4zLCBLdW5pbmdhbiwgU2V0aWEgQnVkaSwgS2VjYW1hdGFuIFNldGlhYnVkaSwgS290YSBKYWthcnRhIFNlbGF0YW4sIERhZXJhaCBLaHVzdXMgSWJ1a290YSBKYWthcnRhIDEwMjUwLCBJbmRvbmVzaWEiJRojChYKFAoSCSH20UED9GkuEc707mF-vRHxEglLQVYuNzYtNzg



回答3:

Although Google does not provide any explanation about the internal implementation of the place_id, it seems to be very similar to a generic GeoHash (such as ElasticSearch uses). Like GeoHashes, the place_id's lengths tend to be longer when they reference a more specific area.

The longest place_id I have seen so far had a length of 78, which was a specific house in large city.



回答4:

That the API does not document the length indicates that it is free to change at any time, and I would not recommend relying on a fixed length - I've seen much longer place_id's while using the API.



回答5:

The length could be event 172 chars:

En_QstGD0LvQuNGG0Y8g0IbQstCw0L3QsCDQkNC60ZbQvdGE0ZbRlNCy0LAsIDE1LCDQlNC90ZbQv9GA0L7MgSwg0JTQvdGW0L_RgNC-0L_QtdGC0YDQvtCy0YHRjNC60LAg0L7QsdC70LDRgdGC0YwsINCj0LrRgNCw0ZfQvdCw


回答6:

I'd use varbinary(1024)

Knowing possible max. length is even more important for input validation than (often prematurely) worrying about the column storage overhead. Most databases share a similar space overhead once you exceed 255.



回答7:

You should not define the length of google place_id because in the API documentation they are not telling the max length of place_id. The only thing they are talking about is place_id can be in a form of long string.

I have taken field type as TextField in Django model.