Javascript 如何从谷歌地图URL获取位置地址?

Javascript 如何从谷歌地图URL获取位置地址?,javascript,api,google-maps,Javascript,Api,Google Maps,给定一个谷歌地图位置的URL,我希望能够获得该位置的地址 例如,给定此URL: 我想知道它的地址: 法国巴黎75007号法国安纳托利大道5号马尔斯广场 你知道我该怎么做吗?我已经研究过谷歌地图API,但还没有找到实现这一点的方法。如果您查看示例URL https://www.google.com/maps/place/Torre+埃菲尔铁塔/@48.8583701,2.2922926,17z/数据=!3m1!4b1!4m5!3m4!10x47E66E2964E34E2D:0x8ddca9ee3

给定一个谷歌地图位置的URL,我希望能够获得该位置的地址

例如,给定此URL:

我想知道它的地址:

法国巴黎75007号法国安纳托利大道5号马尔斯广场


你知道我该怎么做吗?我已经研究过谷歌地图API,但还没有找到实现这一点的方法。

如果您查看示例URL

https://www.google.com/maps/place/Torre+埃菲尔铁塔/@48.8583701,2.2922926,17z/数据=!3m1!4b1!4m5!3m4!10x47E66E2964E34E2D:0x8ddca9ee380ef7e0!8m2!3d48.8583701!4d2.2944813

小心地,您会注意到以下代码在“!1s'和之前'!8m2':

0x47e66e2964e34e2d:0x8ddca9ee380ef7e0

此代码是该位置的要素id。例如,可以使用regexp从URL提取此代码。之后,您可以按“:”分割代码,并使用第二部分(0x8ddca9ee380ef7e0)就地详细信息请求,参数为
cid
。请注意,此参数未公开记录,但在编写此未记录的参数时,其工作原理与预期一致

执行以下请求

https://maps.googleapis.com/maps/api/place/details/json?cid=0x8ddca9ee380ef7e0&key=YOUR_API_KEY

您将得到以下响应

{
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"
}
{
html_属性:[],
结果:{
地址和组件:[
{
长名称:“火星冠军”,
简称:“火星冠军”,
类型:[
“兴趣点”,
“设立”
]
},
{
长_名称:“5”,
简称:“5”,
类型:[
“街道号码”
]
},
{
long_名称:“法国阿纳托利大道”,
简称:“法国阿纳托利大道”,
类型:[
“路线”
]
},
{
长名称:“巴黎”,
简称:“巴黎”,
类型:[
“地点”,
“政治”
]
},
{
long_名称:“巴黎区”,
简称:“巴黎区”,
类型:[
“行政区二级”,
“政治”
]
},
{
龙Î名称:“法兰西Î乐”,
简称:“法兰西之家”,
类型:[
“行政区一级”,
“政治”
]
},
{
龙_名称:“法国”,
简称:“FR”,
类型:[
“国家”,
“政治”
]
},
{
long_名称:“75007”,
简称:“75007”,
类型:[
“邮政编码”
]
}
],
adr_地址:“法国巴黎75007安纳托利大道5号火星冠军酒店”,
地址:法国巴黎75007安纳托利大道5号火星冠军酒店,
格式化的电话号码:“0 892 70 12 39”,
几何图形:{
地点:{
纬度:48.858370099999,
液化天然气:2.2944813
},
视口:{
东北部:{
拉脱维亚:48.8597461302915,
液化天然气:2.29610765
},
西南部:{
纬度:48.85704816970851,
液化天然气:2.29251745
}
}
},
图标:“https://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png",
id:“fd0cfb424bbd79bf28a832e1764f1c2aa5927714”,
国际电话号码:“+33892701239”,
名称:“埃菲尔铁塔”,
开放时间:{
现在就打开吧:没错,
期间:[
{
关闭:{
日期:1,
时间:“0045”
},
开放式:{
日期:0,
时间:“0900”
}
},
{
关闭:{
日期:2,
时间:“0045”
},
开放式:{
日期:1,
时间:“0900”
}
},
{
关闭:{
日期:3,
时间:“0045”
},
开放式:{
日期:2,
时间:“0900”
}
},
{
关闭:{
日期:4,
时间:“0045”
},
开放式:{
日期:3,
时间:“0900”
}
},
{
关闭:{
日期:5,
时间:“0045”
},
开放式:{
日期:4,
时间:“0900”
}
},
{
关闭:{
第6天,
时间:“0045”
},
开放式:{
日期:5,
时间:“0900”
}
},
{
关闭:{
日期:0,
时间:“0045”
},
开放式:{
第6天,
时间:“0900”
}
}
],
工作日文字:[
“星期一:上午9:00–上午12:45”,
“周二上午9:00–12:45”,
“星期三:上午9:00–12:45”,
“周四上午9:00–12:45”,
“星期五:上午9:00–12:45”,
“周六上午9:00–12:45”,
“星期日:上午9:00–上午12:45”
]
},
照片:[
{
身高:408,
html_属性:[
""
],
照片参考:“CmRaAAAAFOGpKiedFvYYu7R7qLkxqdY2GqcGqmHNPvny\U a2dYV81XTFC2RL0ybS-NZg\U oQUa0Fa-U178CBPLmCx8Xz\U PTT16JW87WUM9RdyHovklaaeH52PWCWW1014VU-5EBOEPEHDHT-Gt9o\U 2TEKXWT6FQVxWGHSNNEX49VJOMDIPLXPAZ18YN-”,
宽度:612
},
{
身高:3888,
html_属性:[
""
],
照片参考:“CMRAAAJLOE9SSK1G-d8KTm5dFPw-CAvXd7SK5eg0AS2”ZF7ETSNGDJZPTUPKLRODFE9GFDPRCXYTZIWKOBX2EIEPAMQ_A5G8A7Q905KZ83XIDDJY5D4FbHcQnysrieHBRME9NPMOGWKDFZ2HDJNV3GHRQT2YZDE2ARCDGBWGURIYADP4JW”,
宽度:2592
},
{
身高:600,
html_属性:[
""
],
照片参考:“CmRaAAAAbZO6 2CHJ1TXPNU9-UN01RYHMY7V7HIWB4AUCWWQP8A2XKSLWIHEQZQBG6KGHP0QPKN6NNWHUP9TEVKZUJMPTQVMFHI5ER0WYX-RRHHFSTMBA56QT6V7H4VI297KEHCR-HCQDRTTE0Q3FEQWKLN7PNMXQRYXUXIPWTEVX8W”,
宽度:600
},
{
身高:4160,
html_属性:[
""
],
照片参考:“CmRaAAAA_WjfpbIVJ5zVIy1j-0Q2VKwxGjbGQNzcD9F6rIFEAVqQEvrv_OSRFTX3MAC8NWDOPR163JZGUBEXJKQDCKM-DGR9TQFQFT7FTLBSxTORA6TIA5JIJTKTH-Ivw_UB1; JZJBFRNMC2SLUGHQDXOKL7PLMZPGZ_B38HWIW”,
宽度:2080
},
{
身高:4000,
html_属性:[
""
],
照片参考:“CMRAAAMLY1PGIGZL720KHB\u lfo956P3UX\u rnBZG0KxTImqJCR8sZGHXGv7IdcIM\u c5kaIYLkeG-WwXehU367cLhN8ordS0lqCITaiXL2w2HdL0mABPcr3JYw4fGBsv\u I4ScK-EHCJDIWWEEL5MXVT0YPE10GHTBA4MSOMT9MVEGNGR7AOIJQYX3W”,
宽度:3000
},
{
身高:3648,
html_属性:[
""
],
照片参考:“CMRAAACLC5GWLJxZRPVQI-5X IIFWC6HA1AFYESZDAU7514FU iEYWxVEEgpavyXmC4PU1x-NVVCSOYXVEBCX2WGYP6DMSIGG2WK11HVLZW2OXHAVSIDV2M3QK7HXYHAPEHCIR3DSFJ8DWHTSH4OMKCUQGHRCFAIPKIP0XPHMKFRNFVCGCQ”,
宽度:1744
},
{
身高:3968,
html_属性:[
""
],
照片参考:“CMRAAAAAAwyx”YEDELPVTLGQW9KWQXUXKZDRS9M6GYEMO9HIIJGNSVFW-KYCLF8TEKQXZT9YVSE9SNHMCMZFGR5FKBUBITIZE0WAFNVZYSDQT9TV8NJ009M-FTTB0RX8RC0H70E5EHCIUCNE8JGPBUE7IUMWA0FGHRZBGCB5-35S34I7AIJXU9CEE2JG”,
宽度:2976
},
{
身高:4032,
html_属性:[
""
],
照片参考:“Cmraaaaftsed1er_zkspC7ksk3s22nq69uxytw8dgr7yfcil2q_IJl29yofflEj5HQ8ANuLyQR-NlSYGN3FhnC5jj-zGqUR4wTv-_B-impincvq2mhdz_go43bbc2xqmcgcsecehcr7uryl1qtecundl0f94uw4cyw5jlao-27Gi cIdK9Ic1YFxA”,
宽度:3024
},
{
身高:3024,
html_属性:[
""
],
照片参考:“CMRAAA6A”JRLItYa05p9NcXapox8ROY_H2ID9; 9VEWX1WCHZPP8IBZVA1JHQO9QEFGWYTUUXQ9PU7-XXGKKKGCEPP2SKSDPRRJBFVCMT-ZQUH4LJIGUPU1AAQZMZRVXKBZ2WJHEHBAAIQ2GYTZY7QJBGHTTJ0JGWPIJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJVTXUGUFQWBNNNYW”,
宽度:403