Google Places API place_id field length

淺唱寂寞╮ 提交于 2019-12-04 22:15:52
Andrew

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

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.

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.

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

The length could be event 172 chars:

En_QstGD0LvQuNGG0Y8g0IbQstCw0L3QsCDQkNC60ZbQvdGE0ZbRlNCy0LAsIDE1LCDQlNC90ZbQv9GA0L7MgSwg0JTQvdGW0L_RgNC-0L_QtdGC0YDQvtCy0YHRjNC60LAg0L7QsdC70LDRgdGC0YwsINCj0LrRgNCw0ZfQvdCw

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!