Google maps new !-style embed format
A while ago Google changed the structure of embedded map URLs. The old format used the web-standard key1=value1&key=value2
style, and you can find a reasonably good description of these parameters here. Unfortunately the new style is less verbose and much less intelligible, which seems like a step backwards even if these links are mostly hidden under the surface. Either Google wanted them to be less human-readable, or they care enough about saving a few bytes here and there to do this. I can’t find any good explanation of how to parse these links, so here’s my morning’s attempt. Be warned that this is all guesswork based on a limited sample and some experimentation.
Basic structure #
I’m going to run with the map below as my working example, because I’ll be darned if they don’t draw their fields in perfect repeating 1-mile squares in Iowa. This helps a lot to understand distances in these embeds, which don’t let you measure. Rendered on my laptop, the map below seems to be about 11 miles (squares) wide by 8 miles high.
The embed code for this map is:
<iframe style="border: 0;" src="https://www.google.com/maps/embed?pb=!1m18!1m12!
1m3!1d46806.858602796994!2d-93.27061389999999!3d42.063499449999966!2m3!1f0!2f0!3
f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0x0!2zNDLCsDAzJzQ4LjYiTiA5M8KwMTYnMTQ
uMiJX!5e1!3m2!1sen!2suk!4v1410262779573" width="600" height="450"
frameborder="0"></iframe>
Unlike the previous structure, these embeds have only a single key=value
parameter, ‘pb’. That appears to have an internal structure, delimited by exclamation points (‘bangs’). Each bang-group (call it) starts with an exclamation point, then has a single digit and a single character, followed by variable text. There seem to be two types of entity here:
-
![digit]m[digits]
entities, which seem to indicate the start of a parameter group; at first I thought these were unique in a query but3m2
appears twice, consistently. There’s probably some more structure I haven’t seen. -
other
![digit][char]
entities, which seem to be parameters, where the digit is a sequence number (unique within the parameter group) and the char is a type indicator, with-
d
- double precision floating point -
f
- single precision floating point -
i
- integer -
s
- string -
z
- encoded data or an id or some kind -
b
- byte or boolean (?) -
e
- (?) -
v
- timestamp, unix epoch in milliseconds
-
Parameter groups #
I’m listing these groups in lexicographic order although they typically don’t appear that way in the URL. I haven’t tested whether order makes a difference (presumably not since it’s unique encoded anyway).
1m
-
One of
-
1m14
- just browsing, no marker present -
1m16
- multiple markers (?) -
1m18
- one marker
-
-
1m12
- (?) always seems present -
1m2
- marker / place search, containing-
1s[ref]
- where ref is an ID for the place being marked (this is presumably documented somewhere; it wasn’t important to me) -
One of
-
2s[query]
- the query string / display string for the marker -
2z[data]
- seems to be used to encode coordinates for display
-
-
5e[digit]
- somewhat oddly, this seems to control the map layer: 0 = map, 1 = satellite
-
-
1m3
- map dimensions, containing:-
1d[size]
- where size seems to be smallest side (or maybe just height) in feet (feet!? there are French revolutionaries rolling in their graves). -
2d[longitude]
- of the map centre -
3d[latitude]
- of the map centre
-
2m
-
2m3
- (?), has always contained:-
1f0
- (?) -
2f0
- (?) -
3f0
- (?)
-
3m
-
first
3m2
- screen characteristics (?) - for some abstract display - a complete guess on my part, as changing these seems to make no difference. I suppose this could be based on the settings of the creator, as for the second3m2
below, although they’re always been the same in examples I’ve seen. (But then everyone does use 13” Macbooks now, right?)-
1i[width]
- screen resolution horizontal - has always been 1024 -
2i[height]
- screen resolution vertical - has always been 768 -
4f[diagonal]
- screen size in inches - has always been 13.1
-
-
second
3m2
- creation parameters, containing-
1s[lang]
- a 2-letter language code, which doesn’t seem to affect display, so presumably just records the locale of the creator -
2s[country]
- a 2-letter country code, as for language -
4v[timestamp]
- the unix epoch timestamp described above - when the embed was created
-
Examples #
Map size #
Change the map size to around 2 miles (= 10560 feet):
!1m18!1m12!1m3!1d10560!2d-93.27061389999999!3d42.063499449999966!2m3!1f0!2f0!3f0
!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0x0!2zNDLCsDAzJzQ4LjYiTiA5M8KwMTYnMTQuM
iJX!5e1!3m2!1sen!2suk!4v1410262779573
Map layer #
Change the map layer to road map from satellite.
!1m18!1m12!1m3!1d46806.858602796994!2d-93.27061389999999!3d42.063499449999966!2m
3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0x0!2zNDLCsDAzJzQ4LjYiTiA5
M8KwMTYnMTQuMiJX!5e0!3m2!1sen!2suk!4v1410262779573
Add comment
Comments are moderated and will not appear immediately.
Comments (8)
Thanks for this post! It was so difficult to find something about this cryptography adventure of google!
Have you found if there’s a parameter to control label visibility?
Tim - this post reflects as deep as I dug for what I needed, so probably: no. If you do discover any other parameters, it would be great if you can leave a comment here.
Andrew - thanks for this, I will probably do some experimentation of my own and post back if I come up with any new stuff.
If you’re interested, I have already done a bunch of investigation of the main Google Maps URL structure, with the results posted on my WordPress blog (https://mstickles.wordpress.com/2015/06/12/gmaps-urls-intro/). First use I’ve found for the blog since setting it up.
I suppose 1m3 means “id 1”, structure, 3 elements contained. Did you find out what the “e” means?
I didn’t - but thanks for the suggestion. Useful for others too.
https://cloud.google.com/appengine/docs/python/refdocs/modules/google/appengine/api/datastore_types – perhaps this would help?
Thanks for your (and commenters’ !) great work documenting this odd format. Your investigation was the springboard I needed to solve a tricky problem I was having with parsing these “embed” URLs.
I’ve written it up on my blog here: http://blog.themillhousegroup.com/2016/08/deep-diving-into-google-pb-embedded-map.html
2z[data] is base64-encoded address. F.e. 2zMzAgQm91bGV2YXJkIGRlIEJlbGdpcXVlLCA5ODAwMCBNb25hY28sINCc0L7QvdCw0LrQvg = “30 Boulevard de Belgique, 98000 Monaco, Монако”
Hi, was digging a bit deeper and found the following information to make the embed work with a google maps place: https://stackoverflow.com/questions/38579952/google-places-api-find-a-companys-cid-and-lrd?rq=1
Found that this parameter consisted of two hex encoded values. Example: https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3022.617540796688!2d-73.987853084594!3d40.748440479327876!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0xd134e199a405a163!2sEmpire+State+Building!5e0!3m2!1sde!2sch!4v1538984356906 (this embed code was generated after i used the google map link https://maps.google.com/?cid=15074921902713971043)
[!1s]0x0:0xd134e199a405a163
The parameter 1m2 (1s) is a combination of two hex encoded ids. Found out that the second (d134e199a405a163) is the hex encoded cid (Google maps Customer ID) - You can retrieve this ID over the google places api. Maybe that helps someone who needs the map with the business informations included. The solution with the encoded location only shows a marker for me and not the relevant business. When you search for a business over google maps and grab the map embed code you get a different format with the first hex populated (!= 0x0)
https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d755.6543849789473!2d-73.98621157075722!3d40.74844049870797!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x89c259a9b3117469%3A0xd134e199a405a163!2sEmpire+State+Building!5e0!3m2!1sde!2sch!4v1538984774992
[!1s]0x89c259a9b3117469:0xd134e199a405a163
Seems we don’t need 0x89c259a9b3117469 but still would be nice what it stands for.