Given a URL of a google maps location, I want to be able to get the address of the location.
For example given this URL:
https://www.google.com/maps/place/Eiffe
If you look at the sample URL
https://www.google.com/maps/place/Torre+Eiffel/@48.8583701,2.2922926,17z/data=!3m1!4b1!4m5!3m4!1s0x47e66e2964e34e2d:0x8ddca9ee380ef7e0!8m2!3d48.8583701!4d2.2944813
carefully, you will note the following code after '!1s' and before '!8m2':
0x47e66e2964e34e2d:0x8ddca9ee380ef7e0
.
This code is the feature id of the place. You can extract this code from the URL using regexp for example. After that you can split the code by ':' and use the second part (0x8ddca9ee380ef7e0) in place details request with parameter cid
. Note that this parameter is not publicly documented, but at the moment of writing this undocumented parameter works as expected.
Execute the following request
https://maps.googleapis.com/maps/api/place/details/json?cid=0x8ddca9ee380ef7e0&key=YOUR_API_KEY
You will get the following response
{
html_attributions: [ ],
result: {
address_components: [
{
long_name: "Champ de Mars",
short_name: "Champ de Mars",
types: [
"point_of_interest",
"establishment"
]
},
{
long_name: "5",
short_name: "5",
types: [
"street_number"
]
},
{
long_name: "Avenue Anatole France",
short_name: "Avenue Anatole France",
types: [
"route"
]
},
{
long_name: "Paris",
short_name: "Paris",
types: [
"locality",
"political"
]
},
{
long_name: "Arrondissement de Paris",
short_name: "Arrondissement de Paris",
types: [
"administrative_area_level_2",
"political"
]
},
{
long_name: "Île-de-France",
short_name: "Île-de-France",
types: [
"administrative_area_level_1",
"political"
]
},
{
long_name: "France",
short_name: "FR",
types: [
"country",
"political"
]
},
{
long_name: "75007",
short_name: "75007",
types: [
"postal_code"
]
}
],
adr_address: "Champ de Mars, <span class="street-address">5 Avenue Anatole France</span>, <span class="postal-code">75007</span> <span class="locality">Paris</span>, <span class="country-name">France</span>",
formatted_address: "Champ de Mars, 5 Avenue Anatole France, 75007 Paris, France",
formatted_phone_number: "0 892 70 12 39",
geometry: {
location: {
lat: 48.85837009999999,
lng: 2.2944813
},
viewport: {
northeast: {
lat: 48.8597461302915,
lng: 2.29610765
},
southwest: {
lat: 48.85704816970851,
lng: 2.29251745
}
}
},
icon: "https://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png",
id: "fd0cfb424bbd79bf28a832e1764f1c2aa5927714",
international_phone_number: "+33 892 70 12 39",
name: "Eiffel Tower",
opening_hours: {
open_now: true,
periods: [
{
close: {
day: 1,
time: "0045"
},
open: {
day: 0,
time: "0900"
}
},
{
close: {
day: 2,
time: "0045"
},
open: {
day: 1,
time: "0900"
}
},
{
close: {
day: 3,
time: "0045"
},
open: {
day: 2,
time: "0900"
}
},
{
close: {
day: 4,
time: "0045"
},
open: {
day: 3,
time: "0900"
}
},
{
close: {
day: 5,
time: "0045"
},
open: {
day: 4,
time: "0900"
}
},
{
close: {
day: 6,
time: "0045"
},
open: {
day: 5,
time: "0900"
}
},
{
close: {
day: 0,
time: "0045"
},
open: {
day: 6,
time: "0900"
}
}
],
weekday_text: [
"Monday: 9:00 AM – 12:45 AM",
"Tuesday: 9:00 AM – 12:45 AM",
"Wednesday: 9:00 AM – 12:45 AM",
"Thursday: 9:00 AM – 12:45 AM",
"Friday: 9:00 AM – 12:45 AM",
"Saturday: 9:00 AM – 12:45 AM",
"Sunday: 9:00 AM – 12:45 AM"
]
},
photos: [
{
height: 408,
html_attributions: [
"<a href="https://maps.google.com/maps/contrib/105303505373661530610/photos">Hauser Quaid Zzyzx</a>"
],
photo_reference: "CmRaAAAAFOGpKiedFvYYu7R7qLkxqdY2GqcGqmHNPvny_a2dYV81XTFC2RL0ybS-NZg_oQUa0Fa-U178CBPLmCx8Xz_PTt16jW87WUm9rdYHoVklaAeH52pVuCwW1014vu-5EboPEhDHt-Gt9o_2tEKXWt6FQVXwGhSnNEX49VjoMdiPlXPaZ3z18yN-_A",
width: 612
},
{
height: 3888,
html_attributions: [
"<a href="https://maps.google.com/maps/contrib/101948575993173983825/photos">Gonçalo Borralho</a>"
],
photo_reference: "CmRaAAAAJLOe9SSk1G-d8KTm5dFPw-CAvXd7SK5eg0AS2_zF7eTsNGDJZptupKLRodFE9GfdpRcxYhTzIWkoBx2EIEPamq_A5G8A7Q905KlIkDln6Kz83xIDDjY5D4FBHCQnySriEhBRME9npMoGWKdfz2HDJnV3GhRQT2YZDE2axrCDGbWguRiYaDP4jw",
width: 2592
},
{
height: 600,
html_attributions: [
"<a href="https://maps.google.com/maps/contrib/110560344886268390808/photos">Maria Goryunova</a>"
],
photo_reference: "CmRaAAAAbZO6_2CHj1TxxpNu9-un01rYHMy7v7MhiWB4auCwwqp8a2xkSlWiheQZQBG6kGHp0qPkn6NNwhup9teVKZUjmPTqvMFhI5ER0WyX-RrhHFStBMa5it6qT6V7H4VI297KEhCr-hcQDRTtE0q3fEqWKlnXGhRme7pNMXQRYxuXIpJAkWtEVxQ_Mw",
width: 600
},
{
height: 4160,
html_attributions: [
"<a href="https://maps.google.com/maps/contrib/117413321655290324764/photos">praveen dhingra</a>"
],
photo_reference: "CmRaAAAA_WjfpbIVJ5zVIy1j-0Q2VKwxGjbGQNzcD9F6rIFEAVqQEvrv_OSrfTX3Mac8NwDopr1rl63jZGUbExJkQDckM-DGr9TQqfT7FTLbSxtOra6NTIa5jijTkTh-Ivw_uB1dEhCeiq5yjZZjBfRnmc2SLUxYGhQ4XOKL7PlMZpgZ_Be_b3oK8hHwIw",
width: 2080
},
{
height: 4000,
html_attributions: [
"<a href="https://maps.google.com/maps/contrib/109586342110736030196/photos">H.İbrahim Üzmezoğlu</a>"
],
photo_reference: "CmRaAAAAmLIY1pgIGZL720khB_lfo956P3UX_rnBZG0KxTImqJCR8sZGHXGv7IdcIM_c5kaIYLkeG-WwXehU367cLhN8ordS0lqCITaiXL2w2HdL0mABPcr3JYw4fGBsv_I4ScK-EhCJDIwwlPEel5mXVt0Ype10GhTbA4MsOMt9mVegngR7AOIjqYiX3w",
width: 3000
},
{
height: 3648,
html_attributions: [
"<a href="https://maps.google.com/maps/contrib/104243695644908686665/photos">Kerem Enginar</a>"
],
photo_reference: "CmRaAAAACLc5gwLJxZRPVQI-5X_iI1TyaFwc6HA1aFYeSzDAU7514FU_iEYWxVEEgpavyXmC4PU1x-NVvCSOyxBVEbcX2wgYp6dMsIgg2wK11HvlZW2OxHAVsiDv2m3Qk7hXyhApEhCiR3DSFJ8dwHtsH4OMKCuqGhRcFAIpkIp0XvhAXpHmkFRnfVcGCQ",
width: 1744
},
{
height: 3968,
html_attributions: [
"<a href="https://maps.google.com/maps/contrib/110131594451511930557/photos">LUIS ROLDAN</a>"
],
photo_reference: "CmRaAAAAwyx_YEdelPVTlgqw9KWqXuXKuzDRS9m6gyemO9HIIJGNSVfW-kYClF8TeKqxZt9YvSe9SnhmCMzFGr5fKeKUbiTIz0wAFNvZysdqT9TV8nJ009m-FTtB0Rx8RC0h70e5EhCIUcnE8JgPBue7IUmwOA0fGhRzbGCB5-35S34i7AIaJXu9CEE2jg",
width: 2976
},
{
height: 4032,
html_attributions: [
"<a href="https://maps.google.com/maps/contrib/117736543070762131171/photos">Frank Rafaelsen Lian</a>"
],
photo_reference: "CmRaAAAAFTSEd1eR_zkspc7ksK3S22nq69UXYtW8DGR7B7yfCiL2Q_IJl29yofflEj5HQ8ANuLyQR-NlSYGN3FhnC5jj-zGqUR4wTv-_B-imPEnCvq2mHDz_gO43bbc2xQmcGsecEhCR7Uryl1QTECndlU0f94uuGhT4CYw5JLAO-27Gi_cIdK9Ic1YFxA",
width: 3024
},
{
height: 3024,
html_attributions: [
"<a href="https://maps.google.com/maps/contrib/101863804180255933702/photos">Wadih Antoun</a>"
],
photo_reference: "CmRaAAAA6A_JRLItYa05p9NcXapox8ROY_h2id9AVewX1wChZPP8iBZvA1JHQo9qEFGwyTUuXQ9Pu7-xXgKJkgCepp2SkSdprRjBfvcmt-ZQUH4LjigupU1AAqzMZRVXKbZ2WjHgEhBAIQ2EgygtvhtZSy6Y7QJbGhTLTj0jgWPIJVTxHgUFzqWbnnnymw",
width: 4032
},
{
height: 4224,
html_attributions: [
"<a href="https://maps.google.com/maps/contrib/106542752122609581725/photos">Steve Bird</a>"
],
photo_reference: "CmRaAAAAGbShlT71nLeJHL5sagdgtjssvWCBhDsqPsZ9xeNXu48iFlBsRoRarZZTMUJSK0p2H91Rg27XE8HFCRvvgxLTctA9eJhCktsDoOjP33zw04sX19jrrMhGpS0kOemTV-daEhAz41RPzVtazLhOYKdmkSHqGhRPd9g9S94_N0HrxV9oRcPCHfd2ZQ",
width: 2368
}
],
place_id: "ChIJLU7jZClu5kcR4PcOOO6p3I0",
plus_code: {
compound_code: "V75V+8Q Paris, France",
global_code: "8FW4V75V+8Q"
},
rating: 4.6,
reference: "ChIJLU7jZClu5kcR4PcOOO6p3I0",
reviews: [
{
author_name: "Margaret Bagdon",
author_url: "https://www.google.com/maps/contrib/115820855361415255644/reviews",
language: "en",
profile_photo_url: "https://lh5.googleusercontent.com/-L8M8JctpleE/AAAAAAAAAAI/AAAAAAAAAAA/ACHi3reM2h_11AXwURDawihkuOG34a9MQg/s128-c0x00000000-cc-rp-mo-ba4/photo.jpg",
rating: 4,
relative_time_description: "in the last week",
text: "I purchased tickets on line for 9:00 on a Tues in June. Couldn't print my tickets because of a problem with the account so we showed up early to have them printed. We we're lucky no one was in line at the info booth. We waited in the line (30 minutes) for the time slot we booked. The line to purchase tickets was much longer so I recommend you buy in advance. We rode the glass side lift to the first observation deck and immediately got in line to go to the summit. Waited about 15 minutes. The top was crowded and we watched the sunset from the top. The views are nice so I think it was worth it. You can purchase a small glass of champagne if you want a toast at the top. We took the lift down and stopped for a drink and a rest. We walked the remainder of the way and got down in time to see the brief light show. Good view on the lawn. I would recommend stopping here if it is your first time in Paris and you don't mind heights.....be prepared to wait....and it will be crowded.....and expensive...",
time: 1563234656
},
{
author_name: "Shahrukh Naeem",
author_url: "https://www.google.com/maps/contrib/102499154519714023927/reviews",
language: "en",
profile_photo_url: "https://lh4.googleusercontent.com/-qQBtFB0REZI/AAAAAAAAAAI/AAAAAAAAAAA/ACHi3rd9bYBR5bZcH6BMYaRd5yv2Gw79WQ/s128-c0x00000000-cc-rp-mo-ba5/photo.jpg",
rating: 5,
relative_time_description: "2 weeks ago",
text: "Wonderful romantic place. Must visit with loved ones. Breathtaking view from up the level 2. People can also buy an additional Ticket and go up to the next level to even have a wonderful view or dine with love. Sure a wonder to visit and of course go on top of it. So many romantic couples were taking romantic photos in this structure. In the night there was a five minute light show which has to be viewed from a distance to enjoy how magnificently people made this city a tourist attraction because of this structure",
time: 1562399468
},
{
author_name: "Anca Chelaru",
author_url: "https://www.google.com/maps/contrib/113471456079540231282/reviews",
language: "en",
profile_photo_url: "https://lh4.googleusercontent.com/-UnNJLd9XjiM/AAAAAAAAAAI/AAAAAAAAAAA/ACHi3rcGIic0U1eWvnrKz-xfp2s6mqI2vg/s128-c0x00000000-cc-rp-mo-ba3/photo.jpg",
rating: 5,
relative_time_description: "a week ago",
text: "I loved it! It is better than Empire State Building because you see the empty space going up/down and it gives you an adrenaline rush, that you don't feel in a building. You can take the stairs on the way down, better than the elevator. At the restaurant level, there is glass floor, so you can see all the way down. The gift store at the restaurant level is better than the on on top, it has more staff. Buy the tickets online, saves time. You can easily spend here 1/2 a day.",
time: 1562661564
},
{
author_name: "Jeroen van der Linde",
author_url: "https://www.google.com/maps/contrib/109990025751819839602/reviews",
language: "en",
profile_photo_url: "https://lh5.googleusercontent.com/-g03RbnKDnJ8/AAAAAAAAAAI/AAAAAAAAAAA/ACHi3ren8G7DFs0oZV0hkiYaBdYRydQleQ/s128-c0x00000000-cc-rp-mo-ba6/photo.jpg",
rating: 5,
relative_time_description: "a week ago",
text: "Of course one of the main tourist attractions in Paris, France and even the world. Elevators work now but you can still take the stairs if you want to have a cheaper option to go up. T The direct area is fenced off with high bullet proof glass walls and protected entrances at the sides. Visitors are subject to some screening. If you are looking for pictures of the Eiffel Tower you can also visit the lawn or pond at the sides for better views.",
time: 1562921719
},
{
author_name: "Pratap Ramamoorthy",
author_url: "https://www.google.com/maps/contrib/117384906578505429183/reviews",
language: "en",
profile_photo_url: "https://lh3.googleusercontent.com/-Oo8pn66vGDM/AAAAAAAAAAI/AAAAAAAAA7g/rXZn8xS2bPg/s128-c0x00000000-cc-rp-mo-ba6/photo.jpg",
rating: 5,
relative_time_description: "a month ago",
text: "Wonderful romantic place. Must visit with loved ones. Breathtaking view from up the level 2. People can also buy an additional Ticket and go up to the next level to even have a wonderful view or dine with love. Sure a wonder to visit and of course go on top of it. So many romantic couples were taking romantic photos in this structure. In the night there was a five minute light show which has to be viewed from a distance to enjoy how magnificently people made this city a tourist attraction because of this structure.",
time: 1559894189
}
],
scope: "GOOGLE",
types: [
"premise",
"point_of_interest",
"establishment"
],
url: "https://maps.google.com/?cid=10222232094831998944",
user_ratings_total: 166537,
utc_offset: 120,
vicinity: "Champ de Mars, 5 Avenue Anatole France, Paris",
website: "http://www.toureiffel.paris/"
},
status: "OK"
}
The formatted_address field contains address you are looking for "Champ de Mars, 5 Avenue Anatole France, 75007 Paris, France".
I hope this helps!