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:

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

2m

3m

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
Comments

My blog no longer supports comments, but I have preserved comments on older posts like this one.

Thanks for this post! It was so difficult to find something about this cryptography adventure of google!

Omid

Have you found if there’s a parameter to control label visibility?

Tim

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 Whitby

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.

mstickles

I suppose 1m3 means “id 1”, structure, 3 elements contained. Did you find out what the “e” means?

neil

I didn’t - but thanks for the suggestion. Useful for others too.

Andrew Whitby

https://cloud.google.com/appengine/docs/python/refdocs/modules/google/appengine/api/datastore_types – perhaps this would help?

Kadigan

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

John Marshall (@millhousetweets)

2z[data] is base64-encoded address. F.e. 2zMzAgQm91bGV2YXJkIGRlIEJlbGdpcXVlLCA5ODAwMCBNb25hY28sINCc0L7QvdCw0LrQvg = “30 Boulevard de Belgique, 98000 Monaco, Монако”

noir

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.

Robert Henniger