解码谷歌地图嵌入参数 [英] Decoding the Google Maps embedded parameters

查看:28
本文介绍了解码谷歌地图嵌入参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上下文

我希望能够提取网站中嵌入的 Google 地图的位置(在 本网站).

<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3128.340699934565!2D-0.46482818466529047!3d38.3642391796565!2立方米!1F0!2f0的!3f0!3平方米!1i1024!2i768!4f13.1!3立方米!1平方米!1s0xd62377123a70817%3A0x85e89b65fcf7c648!2sCalle +克鲁兹+的+彼德拉%2C + 4%2C+03015+Alicante!5e0!3m2!1ses!2ses!4v1476192292052" width="100%" height="350" frameborder="0" style="border:0" allowfullscreen=""></iframe>

所以,基本上我想从地图 URL 中提取精确位置:

https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3128.340699934565!2d-0.46482818466529047!3d38.36423917962f!20f!364239179650m!1i1024!2i768!4f13.1!3m3!1m2!1s0xd62377123a70817%3A0x85e89b65fcf7c648!2sCalle+Cruz+de+Piedra%2C+4%2C+!14201203012012012012012012012012014v

网址设计

Google 似乎在这里使用了专有参数设计.这个博客条目这篇 Stackoverflow 帖子 很好地总结了如何理解这些参数.参数的结构类似于 (![id][type][value]),类型为:

m:矩阵f:浮动d:双i:整数b: 布尔值e:枚举(作为整数)s:字符串u:无符号整数

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

有了这些知识,参数可以这样构造:

!1m18!1米12!1立方米!1d3128.340699934565!2d-0.46482818466529047!3d38.3642391796565!2立方米!1f0!2f0!3f0!3平方米!1i1024!2i768!4f13.1!3立方米!1平方米!1s0xd62377123a70817:0x85e89b65fcf7c648!2sCalle Cruz de Piedra, 4, 03015 阿利坎特!5e0!3平方米!1ses!2ses!4v1476192292052

现在看起来很容易,我们几乎可以在明文中看到坐标.但作为 博客条目指出,参数

!1d3128.340699934565!2d-0.46482818466529047!3d38.3642391796565

不是精确定位的位置,而是显示地图的中心.它们很相似,但有时却大不相同.更改坐标和/或地址不会产生不同的地图.

只有在改变参数!1s0xd62377123a70817:0x85e89b65fcf7c648时,地图显示才会中断,这意味着该参数会解码精确点的位置.

只是,用什么编码?

问题

博客条目(从 2016 年 8 月开始),地图链接的构建方式不同.还有另外一个参数在 base64 中对经纬度坐标进行编码:

zMzfCsDQ3JzM0LjUiUyAxNDXCsDAwJzU2LjYiRQ ----base64--->37°47'34.5"S 145°00'56.6"E

以类似的方式,这个新参数的坐标应该有望解码:

0xd62377123a70817:0x85e89b65fcf7c648 ----????---->38.364236,-0.462649

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

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

解决方案

这个中间不是最终答案,后续有后续)),只是一些想法

未记录的方法.(用 tfid 代替 placeid)
Places API 网络服务
以后不保修:

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 密钥设置 API 密钥

来自 Google 的回答:(JSON - 光解析)

<代码>{"html_attributions" : [],结果" : {地址组件":[{"long_name": "4","short_name" : "4",类型":[street_number"]},{"long_name": "Calle Cruz de Piedra","short_name": "Calle Cruz de Piedra",类型":[路线"]},{"long_name" : "Alacant","short_name" : "Alacant",类型":[地方",政治"]},{"long_name": "阿利坎特","short_name" : "A",类型":[administrative_area_level_2",political"]},{"long_name": "Comunidad Valenciana","short_name" : "Comunidad Valenciana",类型":[administrative_area_level_1",political"]},{"long_name": "西班牙","short_name" : "ES",类型":[国家",政治"]},{"long_name": "03015","short_name": "03015",类型":[邮政编码"]}],"adr_address" : "u003cspan class="street-address"u003eCalle Cruz de Piedra, 4u003c/spanu003e, u003cspan class="postal-code"u003e03015u003c/spanu0u003cspan class="locality"u003eAlacantu003c/spanu003e, u003cspan class="region"u003eAlicanteu003c/spanu003e, u003cspan class="country-name"3cu00/spanu003e","formatted_address": "Calle Cruz de Piedra, 4, 03015 Alacant, Alicante, Spain",几何学" : {地点" : {纬度":38.3642358,lng":-0.4626489},视口":{东北":{纬度":38.3655847802915,lng":-0.4612999197084979},西南":{纬度":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",参考": CmRbAAAAn6NLYXEs-ttLvUlgjnh5aDHt-LR_hXe6JmUN8fzv6MJ7Q50xt_zUU_WlTc3aL_BQc70-1YjEb6Soluro5rA8cIFJG_w08RSr_JWo_SFEFc1Ncme_dKVKsPX6Q0LtO8gWEhACTzabAMLQfM5xt1_BNsywGhSZr0WRGlutqeuRgs-IY41ndk3yoQ",范围":谷歌",类型":[街道地址"],"url" : "https://maps.google.com/?q=Calle+Cruz+de+Piedra,+4,+03015+Alacant,+Alicante,+Spain&ftid=0xd62377123a70817:0x85e89b65fcf7c648",utc_offset":60,附近":阿拉坎特"},状态":好的"}

<小时>

设置 API 密钥

如果您的客户端应用程序不使用 OAuth 2.0,那么它在调用在 Google Cloud Platform 项目中启用的 API 时必须包含 API 密钥.应用程序将此密钥作为 key=API_key 参数传递到所有 API 请求中.要创建应用程序的 API 密钥:

  1. 转到API 控制台.
  2. 从项目列表中,选择一个项目或创建一个新项目.
  3. 如果 API 和服务页面尚未打开,打开左侧菜单并选择APIs &服务.
  4. 在左侧,选择凭据.
  5. 点击创建凭据,然后选择API 密钥.

注意:除了阅读此页面上的说明外,请务必阅读安全使用 API 密钥的最佳做法.

<小时>

(草稿)未删除历史记录

仅供测试!临时解决方案:

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)" |查找 """0xd62377123a70817:0x85e89b65fcf7c648"","

在命令提示符下回答:,["0xd62377123a70817:0x85e89b65fcf7c648",null,null,[null,null,38.364235799999996,-0.4626489]

卷曲那里(如果需要)

继续搜索....

<小时>

我认为,这个 (0xd62377123a70817:0x85e89b65fcf7c648) 是 GoogleMap 数据库中地图对象的 ID.当点击 URL1 时.

例如

如果你想要地理坐标,请点击 URL2,然后如果需要创建链接为 EMBED 没问题,结果如下:

src="https://www.google.com/maps/embed?pb=!1米18!1米12!1立方米!1d782.0856626047412!2d-0.46311117079625247!3d38.36419405026406!2立方米!1f0!2f0!3f0!3平方米!1i1024!2i768!4f13.1!3立方米!1平方米!1s0x0%3A0x0!2zMzjCsDIxJzUxLjEiTiAwwrAyNyc0NS4yIlc!5e0!3平方米!1ses!2ses!4v1509474812934"

它是 FTID (0xd62377123a70817:0x85e89b65fcf7c648)
ftid 参数是某些地图对象的唯一标识符,就像 fid 和 cid 一样.需要在地图上但不属于本地数据库的位置由 ftid 参数标识.无法通过 Places 声明这些类型的 Maps 对象.

API Google Places 和其他人使用 place-id

for (Calle Cruz de Piedra, 4 03015 Alicante) place-id = ChIJFwinI3E3Yg0RSMb3_GWb6IU

(地点 -> 地点 ID)
https://developers.google.com/maps/documentation/javascript/examples/places-placeid-finder
和反向(地点ID->地点)https://developers.google.com/maps/documentation/javascript/examples/geocoding-place-id

现在:

place-idlocation - ok
https://developers.google.com/maps/documentation/geocoding/intro?hl=en#ReverseGeocoding

FTIDlocation -?问题开放...快速和自动

Google 的方式:

https://google.com/maps?ftid=0xd62377123a70817897a70817897a708178fc648

https://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%3A0x44604624>p

还有两个关于 Google Maps Embed API 的词:

m 使用以下语法创建块:1 数字 - ID 还是当前块中的位置?2 数字 - 值 = 新区块的大小

!m

!1m3!3平方米!1m1!1s0xd62377123a70817%3A0x85e89b65fcf7c648{}{,,{}}{,,{{}}}{,,{{1s}}}!1:{}!1:{!3:{}}!1:{!3:{!1:{}}}!1:{!3:{!1:{1s}}}

我希望这会有所帮助!

The context

I would like to be able to extract the location of Google Maps embedded in a website (random example found at the bottom of 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>

So, basically I want to extract the pinpoint location from the Maps 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

The URL design

Google seems to use a proprietary parameter design here. This blog entry and this Stackoverflow post did a good job summarizing how these parameters can be understood. The parameters are structured like (![id][type][value]), with types:

m: matrix
f: float
d: double
i: integer
b: boolean
e: enum (as integer)
s: string
u: unsigned int

Matrices can encapsulate multiple data entries, e. g. !1m3!1i2!1i4!1i17 means that the matrix with the ID 1 contains the three integer values [2, 4, 17].

With this knowledge, the parameters can be structured like this:

!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

Now it seems to be easy, we see coordinates almost in clear-text. But as the blog entry points out, the parameters

!1d3128.340699934565
!2d-0.46482818466529047
!3d38.3642391796565

are not the position of the pinpoint, but the center of the shown map. They are similar, but at times very different. Changing the coordinates and/or the address will not result in a different map.

Only when changing the parameter !1s0xd62377123a70817:0x85e89b65fcf7c648, the map display will break, meaning this parameter decodes the location of the pinpoint.

Just, in what encoding?

The question

In the blog entry (from August 2016), the Maps link is built up differently. There is another parameter which encodes the longitude and latitude coordinates in base64:

zMzfCsDQ3JzM0LjUiUyAxNDXCsDAwJzU2LjYiRQ ----base64---> 37°47'34.5"S 145°00'56.6"E

In a similar manner, the coordinates of this new parameter should hopefully decode:

0xd62377123a70817:0x85e89b65fcf7c648 ----????----> 38.364236,-0.462649

It looks like hexadecimal encoding, but when converting to integer (964394229279688727:9649133063979386440), this does not correspond to geographic coordinates in a system I know.

So, who can crack the code? Any help appreciated.

解决方案

This intermediate is not the final answer, and the sequel follows)), just some thoughts

Undocumented method. (with tfid instead placeid)
Places API Web Service
No warranty in future:

https://maps.googleapis.com/maps/api/place/details/json?key=YOUR_API_KEY&ftid=0xd62377123a70817:0x85e89b65fcf7c648&

The documented request is:

https://maps.googleapis.com/maps/api/place/details/json?key=YOUR_API_KEY&placeid=ChIJFwinI3E3Yg0RSMb3_GWb6IU

Need API KEY for this requests Setting up API keys

Answer from Google: (JSON - light parsing)

{
   "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, 4u003c/spanu003e, u003cspan class="postal-code"u003e03015u003c/spanu003e u003cspan class="locality"u003eAlacantu003c/spanu003e, u003cspan class="region"u003eAlicanteu003c/spanu003e, u003cspan class="country-name"u003eSpainu003c/spanu003e",
      "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"
}


Setting up API keys

If your client application does not use OAuth 2.0, then it must include an API key when it calls an API that's enabled within a Google Cloud Platform project. The application passes this key into all API requests as a key=API_key parameter. To create your application's API key:

  1. Go to the API Console.
  2. From the projects list, select a project or create a new one.
  3. If the APIs & services page isn't already open, open the left side menu and select APIs & services.
  4. On the left, choose Credentials.
  5. Click Create credentials and then select API key.

Note: In addition to reading the instructions on this page, be sure to read Best practices for securely using API keys.


(draft) not deleted for history

for test only! temporary solution:

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"","

Answer in command prompt: ,["0xd62377123a70817:0x85e89b65fcf7c648",null,null,[null,null,38.364235799999996,-0.4626489]

CURL there if needed

search to be continued....


I think, this (0xd62377123a70817:0x85e89b65fcf7c648) is ID of map object in GoogleMap database. When click URL1.

For Example

if you want geographic coordinates then click URL2 please and next if need create link as EMBED no problem, result below:

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" 

it is FTID (0xd62377123a70817:0x85e89b65fcf7c648)
The ftid parameter is a unique identifier for certain map objects, just as fid and cid are. Locations that need to be on the map but are not part of the Local database are identified by the ftid parameter. It is not possible to claim these type of Maps objects through Places.

API Google Places and others work with place-id

for (Calle Cruz de Piedra, 4 03015 Alicante) place-id = ChIJFwinI3E3Yg0RSMb3_GWb6IU

(place -> place-id)
https://developers.google.com/maps/documentation/javascript/examples/places-placeid-finder
and Reverse (place-id->place) https://developers.google.com/maps/documentation/javascript/examples/geocoding-place-id

NOW:

place-id to location - ok
https://developers.google.com/maps/documentation/geocoding/intro?hl=en#ReverseGeocoding

FTID to location -? question open... for fast and automatic

way over Google:

https://google.com/maps?ftid=0xd62377123a70817:0x85e89b65fcf7c648

https://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

for Atlantic Ocean work too:
https://google.com/maps?ftid=0xadd28c30ec90d79%3A0x44652457c0696504

and two words about 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 create Block with this syntax: 1 Digital - ID or place in current block? 2 Digital - value = size of new block

!<ID>m<value>

!1m3
!3m2
!1m1
!1s0xd62377123a70817%3A0x85e89b65fcf7c648

{}
{,,{}}
{,,{{}}}
{,,{{1s}}}

!1:{}
!1:{!3:{}}
!1:{!3:{!1:{}}}
!1:{!3:{!1:{1s}}}

I hope this helps!

这篇关于解码谷歌地图嵌入参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆