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 (with braces replacing the angled brackets):

{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!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0x0!2zNDLCsDAzJzQ4LjYiTiA5M8KwMTYnMTQuMiJX!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 but 3m2 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 second 3m2 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!2zNDLCsDAzJzQ4LjYiTiA5M8KwMTYnMTQuMiJX!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!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0x0!2zNDLCsDAzJzQ4LjYiTiA5M8KwMTYnMTQuMiJX!5e0!3m2!1sen!2suk!4v1410262779573

9 comments

    1. 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.

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s