google-maps - 解码谷歌地图嵌入参数

标签 google-maps iframe google-maps-api-3 geolocation geospatial

上下文

我希望能够提取嵌入网站的谷歌地图的位置(在 this website 底部找到的随机示例)。

<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3128.340699934565!2d-0.46482818466529047!3d38.3642391796565!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0xd62377123a70817%3A0x85e89b65fcf7c648!2sCalle+Cruz+de+Piedra%2C+4%2C+03015+Alicante!5e0!3m2!1ses!2ses!4v1476192292052" width="100%" height="350" frameborder="0" style="border:0" allowfullscreen=""></iframe>


所以,基本上我想从 map URL 中提取精确位置:
https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3128.340699934565!2d-0.46482818466529047!3d38.3642391796565!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0xd62377123a70817%3A0x85e89b65fcf7c648!2sCalle+Cruz+de+Piedra%2C+4%2C+03015+Alicante!5e0!3m2!1ses!2ses!4v1476192292052

网址设计

谷歌似乎在这里使用了专有的参数设计。 blog entrythis Stackoverflow post 很好地总结了如何理解这些参数。参数的结构类似于 (![id][type][value]),类型为:
m: matrix
f: float
d: double
i: integer
b: boolean
e: enum (as integer)
s: string
u: unsigned int

矩阵可以封装多个数据条目,例如。 G。 !1m3!1i2!1i4!1i17 表示 ID 为 1 的矩阵包含三个整数值 [2, 4, 17]

有了这些知识,参数可以这样构造:
!1m18
  !1m12
    !1m3
      !1d3128.340699934565
      !2d-0.46482818466529047
      !3d38.3642391796565
    !2m3
      !1f0
      !2f0
      !3f0
    !3m2
      !1i1024
      !2i768
      !4f13.1
  !3m3
    !1m2
      !1s0xd62377123a70817:0x85e89b65fcf7c648
      !2sCalle Cruz de Piedra, 4, 03015 Alicante
  !5e0
!3m2
  !1ses
  !2ses
!4v1476192292052

现在看起来很容易,我们几乎可以以明文形式看到坐标。但正如 the blog entry 指出的那样,参数
!1d3128.340699934565
!2d-0.46482818466529047
!3d38.3642391796565

不是精确定位的位置,而是所示 map 的中心。它们很相似,但有时非常不同。更改坐标和/或地址不会产生不同的 map 。

只有在更改参数 !1s0xd62377123a70817:0x85e89b65fcf7c648 时, map 显示才会中断,这意味着该参数会解码精确定位的位置。

只是,用什么编码?

问题

the blog entry(从 2016 年 8 月开始)中, map 链接的构建方式有所不同。还有一个参数可以编码base64中的经度和纬度坐标:
zMzfCsDQ3JzM0LjUiUyAxNDXCsDAwJzU2LjYiRQ ----base64---> 37°47'34.5"S 145°00'56.6"E

以类似的方式,这个新参数的坐标应该有望解码:
0xd62377123a70817:0x85e89b65fcf7c648 ----????----> 38.364236,-0.462649

它看起来像十六进制编码,但是当转换为整数( 964394229279688727:9649133063979386440 )时,这与我所知道的系统中的地理坐标不对应。

那么,谁能破解密码呢?任何帮助表示赞赏。

最佳答案

这个中间不是最终的答案,后面有续集)),只是一些想法
未记录的方法。 (使用 ftid 而不是 place_id 参数)
Places API Web Service
future 不保修:

https://maps.googleapis.com/maps/api/place/details/json?key=YOUR_API_KEY&ftid=0xd62377123a70817:0x85e89b65fcf7c648&
记录在案的请求是:
https://maps.googleapis.com/maps/api/place/details/json?key=YOUR_API_KEY&placeid=ChIJFwinI3E3Yg0RSMb3_GWb6IU
此请求需要 API KEY Setting up API keys
来自 Google 的回答:(JSON - 轻量级解析)
{
   "html_attributions" : [],
   "result" : {
      "address_components" : [
         {
            "long_name" : "4",
            "short_name" : "4",
            "types" : [ "street_number" ]
         },
         {
            "long_name" : "Calle Cruz de Piedra",
            "short_name" : "Calle Cruz de Piedra",
            "types" : [ "route" ]
         },
         {
            "long_name" : "Alacant",
            "short_name" : "Alacant",
            "types" : [ "locality", "political" ]
         },
         {
            "long_name" : "Alicante",
            "short_name" : "A",
            "types" : [ "administrative_area_level_2", "political" ]
         },
         {
            "long_name" : "Comunidad Valenciana",
            "short_name" : "Comunidad Valenciana",
            "types" : [ "administrative_area_level_1", "political" ]
         },
         {
            "long_name" : "Spain",
            "short_name" : "ES",
            "types" : [ "country", "political" ]
         },
         {
            "long_name" : "03015",
            "short_name" : "03015",
            "types" : [ "postal_code" ]
         }
      ],
      "adr_address" : "\u003cspan class=\"street-address\"\u003eCalle Cruz de Piedra, 4\u003c/span\u003e, \u003cspan class=\"postal-code\"\u003e03015\u003c/span\u003e \u003cspan class=\"locality\"\u003eAlacant\u003c/span\u003e, \u003cspan class=\"region\"\u003eAlicante\u003c/span\u003e, \u003cspan class=\"country-name\"\u003eSpain\u003c/span\u003e",
      "formatted_address" : "Calle Cruz de Piedra, 4, 03015 Alacant, Alicante, Spain",
      "geometry" : {
         "location" : {
            "lat" : 38.3642358,
            "lng" : -0.4626489
         },
         "viewport" : {
            "northeast" : {
               "lat" : 38.3655847802915,
               "lng" : -0.4612999197084979
            },
            "southwest" : {
               "lat" : 38.3628868197085,
               "lng" : -0.463997880291502
            }
         }
      },
      "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png",
      "id" : "ce1aa5a252b86d559268866a6a4858db9bba3dff",
      "name" : "Calle Cruz de Piedra, 4",
      "place_id" : "ChIJFwinI3E3Yg0RSMb3_GWb6IU",
      "reference" : "CmRbAAAAn6NLYXEs-ttLvUlgjnh5aDHt-LR_hXe6JmUN8fzv6MJ7Q50xt_zUU_WlTc3aL_BQc70-1YjEb6Soluro5rA8cIFJG_w08RSr_JWo_SFEFc1Ncme_dKVKsPX6Q0LtO8gWEhACTzabAMLQfM5xt1_BNsywGhSZr0WRGlutqeuRgs-IY41ndk3yoQ",
      "scope" : "GOOGLE",
      "types" : [ "street_address" ],
      "url" : "https://maps.google.com/?q=Calle+Cruz+de+Piedra,+4,+03015+Alacant,+Alicante,+Spain&ftid=0xd62377123a70817:0x85e89b65fcf7c648",
      "utc_offset" : 60,
      "vicinity" : "Alacant"
   },
   "status" : "OK"
}

设置 API key
如果您的客户端应用程序不使用 OAuth 2.0,那么它在调用在 Google Cloud Platform 项目中启用的 API 时必须包含 API key 。应用程序将此 key 作为 key=API_key 参数传递给所有 API 请求。
创建应用程序的 API key :
  • 转至API Console .
  • 从项目列表中,选择一个项目或创建一个新项目。
  • 如果 API 和服务页面尚未打开,请打开左侧
    菜单并选择 API 和服务 .
  • 在左侧,选择 证书。
  • 点击创建凭据 然后选择 API key .

  • 注:除了阅读本页的说明,请务必阅读 Best practices for securely using API keys .

    (草案)未删除历史记录
    仅供测试!临时解决方案:
    curl "https://www.google.com/maps/place/data=!4m2!3m1!1s0xd62377123a70817:0x85e89b65fcf7c648" -s -b -L -H "user-agent: Googlebot/2.1 (+http://www.google.com/bot.html)" | FIND """0xd62377123a70817:0x85e89b65fcf7c648"","
    
    在命令提示符下回答:
    ,["0xd62377123a70817:0x85e89b65fcf7c648",null,null,[null,null,38.364235799999996,-0.4626489]
    CURL there如果需要的话
    搜索继续......

    我认为,这个 (0xd62377123a70817:0x85e89b65fcf7c648) 是 GoogleMap 数据库中 map 对象的 ID。单击 URL1 时。
    For Example
    如果你想要地理坐标,请点击 URL2,如果需要创建链接作为嵌入没问题,结果如下:
    src="https://www.google.com/maps/embed?pb=
    !1m18
        !1m12
            !1m3
                !1d782.0856626047412
                !2d-0.46311117079625247
                !3d38.36419405026406
            !2m3
                !1f0
                !2f0
            !3f0
            !3m2
                !1i1024
                !2i768
            !4f13.1
        !3m3
            !1m2
                !1s0x0%3A0x0
                !2zMzjCsDIxJzUxLjEiTiAwwrAyNyc0NS4yIlc
        !5e0
    !3m2
       !1ses
       !2ses
    !4v1509474812934" 
    
    它是 FTID (0xd62377123a70817:0x85e89b65fcf7c648)
    ftid 参数是某些 map 对象的唯一标识符,就像 fid 和 cid 一样。
    需要在 map 上但不属于本地数据库的位置由 ftid 参数标识。无法通过 Places 声明这些类型的 Maps 对象。
    API Google Places和其他人一起使用 place-id
    为(Calle Cruz de Piedra, 4 03015 Alicante)place-id = ChIJFwinI3E3Yg0RSMb3_GWb6IU(地点->地点ID)
    https://developers.google.com/maps/documentation/javascript/examples/places-placeid-finder
    和反向(place-id->place)
    https://developers.google.com/maps/documentation/javascript/examples/geocoding-place-id
    现在:place-idlocation - 行
    https://developers.google.com/maps/documentation/geocoding/intro?hl=en#ReverseGeocodingFTIDlocation -?问题开放......快速和自动
    超越谷歌:
    https://google.com/maps?ftid=0xd62377123a70817:0x85e89b65fcf7c648https://www.google.com/maps/place/Calle+Cruz+de+Piedra,+4,+03015+Alicante,+%D0%98%D1%81%D0%BF%D0%B0%D0%BD%D0%B8%D1%8F/ @38.3642358,-0.4648376 ,17z/data=!3m1!4b1!4m5!3m4!1s0xd62377123a70817:0x85e89b65fcf7c648!8m2!3d38.3642358!4d-0.4626489也适用于大西洋工作:
    https://google.com/maps?ftid=0xadd28c30ec90d79%3A0x44652457c0696504
    以及关于 Google Maps Embed API 的两个词:

    <iframe 
    src="https://www.google.com/maps/embed?pb=
    !1m3
    !3m2
    !1m1
    !1s0xd62377123a70817%3A0x85e89b65fcf7c648"
    width="400" height="400" frameborder="0" style="border:0" allowfullscreen>
    </iframe>
    m使用以下语法创建 block :
    1 数字 - ID 或当前 block 中的位置?
    2 数字 - 值 = 新 block 的大小!<ID>m<value>
    !1m3
    !3m2
    !1m1
    !1s0xd62377123a70817%3A0x85e89b65fcf7c648
    
    {}
    {,,{}}
    {,,{{}}}
    {,,{{1s}}}
    
    !1:{}
    !1:{!3:{}}
    !1:{!3:{!1:{}}}
    !1:{!3:{!1:{1s}}}
    
    我希望这有帮助!

    关于google-maps - 解码谷歌地图嵌入参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47017387/

    相关文章:

    javascript - 如何在多边形上打洞以在 Google map 上以干净的颜色显示每个多边形?

    android - 在 android 中的谷歌地图上加载假 map

    javascript - Google Maps Api V3 - 将多个监听器分配给同一标记对象

    javascript - 在 iframe 中显示部分 DIV

    javascript - 我们可以从 iframe 本身打开的页面关闭 iframe 窗口吗?

    javascript - 我们可以让 Google Maps Javascript Geocoding API v3 在响应中返回自定义标识符吗?

    javascript - 在不同的叠加层之间切换(Google map )

    javascript - 谷歌地图点击事件无法完全正确工作

    jquery - 一页上有多个谷歌地图

    forms - 在 iframe 中提交表单并重定向整个页面