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.