New Google Maps URLs – Directions Options (Part 1)

This is the first in a set of posts covering the options for directions requests. This post will look at selecting transportation type, distance units, and specific route (when multiple routes are returned), as well as displaying route details.


Maps can provide directions for five different ways of “getting around” – driving, bicycling, walking, transit, and flight. You select one via the !3e# tag. The available values are:

0 = Driving
1 = Bicycling
2 = Walking/Hiking
3 = Transit
4 = Flight

If this element is omitted, Maps will choose the fastest route(s) from among all transportation types. Only one can be selected, so (for example) it is not possible to look at only driving and transit routes while excluding bicycling, walking and flights.

The transportation type element is contained within the directions marker element, which is itself contained within the map/route/display contents element. So if your only data option was specifying transit routes, the data options section would look like:

/data=!4m2!4m1!3e3

The possible distance units are kilometers (km) and miles. By default, Maps will choose the one appropriate for the area you are getting directions in, so if you check the route from Edmonton to Ottawa in Canada you will see kilometers, but checking the route from Detroit to Chicago in the US will give you miles. The starting point is the controlling factor, so if you ask for directions from Detroit to Ottawa you will see miles, but if you reverse the route you will see kilometers.

To select one or the other, use the !4e# element, with a value of 0 indicating kilometers and 1 indicating miles.

This element is also under the two ‘4m’ elements, so if we ask for walking directions in miles, the data options section would look like:

/data=!4m3!4m2!3e3!4e1

Interesting note: if you select kilometers using the 4e0 element, Maps will delete the element from the URL after rendering the map. Changing the map from the web interface (other than changing the distance units) will maintain the use of kilometers, but if you update the URL without re-entering the 4e0 element, Maps will use the default units for the route requested.


If Maps returns more than one route for a directions request, the one to select can be specified via the !5i# element. The value is zero-based, so if Maps returns three route possibilities, they would correspond to values 0, 1, and 2 in whatever order of preference Maps uses.

So, if you only wanted driving routes and wanted the second route from the list to be selected, the data options section would look like:

/data=!4m3!4m2!3e0!5i1

If the specified route is out of range (for example, Maps only returned two routes but you used !5i2 to get the third one), Maps will “select” the first route but it will not be highlighted on the map display.


Route details are requested by using the /am=t tag. This causes the directions box on the left to display the section containing details of your route. However, this does not expand the various sections to reveal the turn-by-turn details automatically; you will need to do that manually.


Return to New Google Maps URLs introduction

Posted in Google Maps, Online Maps | Tagged , | Leave a comment

New Google Maps URLs – Map Appearance Options

This post will cover two options dealing with map appearance: image type and map layers.


There are two image types possible for regular maps – street map and satellite imagery. In the Maps interface, these are controlled by a clickable box in the lower left which will say either “Satellite” or “Map” (it always shows the opposite of what is currently displayed). Technically, what Maps currently calls “Satellite” is more like Classic Maps’ “Hybrid” view, in that both satellite imagery and street map symbols are displayed; there does not appear to be any way to get a pure satellite image without map symbols.

Map view is set using option !3m1!1e0, although since this is the default setting it can be omitted. Satellite view is set using option !3m1!1e3. Multiple options are not possible; if you tried using !3m2!1e0!1e3 or !3m1!1e0!3m1!1e3, Maps would only apply the last one specified.


There are six different map layers that I have identified – traffic, transit, bicycling, terrain, images, and flights.

Layers are specified using the following format:

!5mN/!1eL1/!1eL2//!1eLN

The layer values are:

1 = Traffic (real time)
2 = Transit (i.e., bus lines, light rail, etc)
3 = Bicycling (i.e., bike paths)
4 = Terrain
5 = Images (i.e., where Street View is available)
6 = Flights

So, if you wished to specify the terrain and traffic layers, the option set could look like:

!5m2!1e1!1e4

Note that not all layers are compatible with each other. Traffic is not compatible with bicycling, transit, or images, and bicycling is also not compatible with transit or flights. If you specify a set of layers that includes one or more incompatibilities, Maps will resolve these from last to first, like this:

!5m4!1e4!1e2!1e1!1e3

!1e3 is Bicycling – included
!1e1 is Traffic – incompatible with Bicycling; omitted
!1e2 is Transit – incompatible with Bicycling; omitted
!1e4 is Terrain – compatible with Bicycling; included

If multiple layers are specified in the URL, after resolving incompatibilities and rendering what it can, Maps will alter the URL to only include one layer (specifically, the last layer in the list which is not the Images layer) and will display the box on the left side which includes the options or notes for that layer.

There are two exceptions to the above rules that I have noticed.

  1. If the Bicycling and Flights layers are both specified, then even if the Bicycling layer comes after the Flights layer in the URL, Maps will not display the Bicycling layer. However, the layer box will still display the Bicycling layer information if that layer was last in the URL.
  2. If the Images layer is specified anywhere in the URL list and is not omitted due to compatibility rules, the layer box will show the Images layer information.

A few final notes:

  • The Flights layer currently does not appear to display any flight-related information. It might need to be associated with personal flight information from the user’s Google+ account, or perhaps it is functionality that is under development; I just don’t know.
  • Transit will display transit routes but only in limited areas; apparently not much transit information is available in the Google Maps system at this time.
  • There is apparently no way to specify a day and time for the Traffic layer; only live traffic is available via the URL. You can, of course, select “Typical Traffic” in the Maps interface, but if you had more than one layer up the non-traffic layer(s) will be lost when you do this.

Return to New Google Maps URLs introduction

Posted in Google Maps, Online Maps | Tagged , | Leave a comment

New Google Maps URLs – Data Options Reference

Maps’ data options are located following the term /data= in the URL. The options section is made up of one or more elements, each of which have the following general format:

  • An exclamation point (!) as the first character
  • An index number which indicates what this element represents (meaning is context-sensitive).
  • A letter indicating the data type
  • The value of the element.

The following data types have been observed:

  • b – Binary (0 = off/no, 1 = on/yes)
  • d – Decimal (value is a decimal – i.e., floating-point – number)
  • e – Enumerated (0 = 1st option, 1 = 2nd option, etc.)
  • i – Integer (value is a numeric integer)
  • j – Julian Date? (value is an integer indicating the number of seconds since the start of Jan 1, 1970)
  • m – Marker? (marks the start of a collection of elements; value is an integer indicating the number of following elements “contained” by this one)
  • s – String (value is a text string, possibly an encoding of some sort)

The following data elements have been observed (some identifications are tentative, or just educated guesses):

  • 3m   Type of map/display
    • 1e   Type of map/display
      • 1e0 = Street Map
      • 1e1 = Street View or See Inside
      • 1e2 = User Photos
      • 1e3 = Satellite
    • 3m   Photo/image information
      • 1s   Unknown
      • 2e   Unknown
      • 3e   Unknown
      • 6s   URL of the photo/image content
      • 7i   Uncertain, possibly image width in pixels
      • 8i   Uncertain, possibly image height in pixels
    • 4b   Uncertain. Maps occasionally inserts this as a ‘!3m1!4b1’ block. When used with a place request, including it seems to override the MAP_POSITION section and zoom in on the requested place.
  • 4m   Map/route/display contents
    • 3m   Unknown (appears to be related to Street View)
      • 1s   Unknown
    • 4m   Directions
      • 1m   Stop along the route
        • 1m   Stop stored details
          • 1s   Encoded string
        • 2m   Stop stored location
          • 1d   Longitude (decimal degrees)
          • 2d   Latitude (decimal degrees)
        • 3m   Waypoint encountered after this stop
          • 1m   Waypoint location
            • 1d   Longitude (decimal degrees)
            • 2d   Latitude (decimal degrees)
          • 3s   Waypoint stored details (encoded string)
      • 2m   Route options
        • 1b   Avoid highways
        • 2b   Avoid tolls
        • 3b   Avoid ferries
        • 4e   Preferred transit criterion (mutually exclusive; uses final one)
          • 4e0, 4e1 = Prefer best route (i.e., fastest time) (default); not sure what the difference is, or if there even is one
          • 4e2 = Prefer fewest transfers
          • 4e3 = Prefer less walking
        • 5e   Preferred transit type (multiple OK)
          • 5e0 = Bus
          • 5e1 = Subway
          • 5e2 = Train
          • 5e3 = Tram/light rail
          • Omitted = Any
        • 6e   Designate arrival/departure time (mutually exclusive; uses final one). Appears to have no effect without the 8j element.
          • 6e0 = Depart at (default)
          • 6e1 = Arrive by
          • Omitted = Do not use arrival/departure time
        • 7e   Uncertain. Appears to have no effect without 8j element. If omitted, arrival/departure time used is four hours before the specified time.
          • 7e2 = Only value that appears to allow arrival/departure time to work properly
        • 8j   Arrival/departure time specification.
      • 3e   Type of transportation to use (mutually exclusive; uses final one)
        • 3e0 = Driving (car)
        • 3e1 = Bicycling
        • 3e2 = Walking/Hiking
        • 3e3 = Transit
        • 3e4 = Flight
        • Omitted = Any
      • 4e   Distance units to use (mutually exclusive; uses final one)
        • 4e0 = Kilometers
        • 4e1 = Miles
        • Omitted = Automatic (default for that area)
      • 5i   Route to select (mutually exclusive; uses final one). Zero-based integer index, so ‘5i0’ means select the first route, ‘5i1’ the second, etc. If the value is higher than the number of routes returned, the first route will be “selected” but not highlighted on the map.
  • 5m   Map layers
    • 1e   Type of layer (multiple OK; in conflicts, priority goes to last listed)
      • 1e1 = Traffic
      • 1e2 = Transit
      • 1e3 = Bicycling
      • 1e4 = Terrain
      • 1e5 = Images (Street View, Photo Spheres, See Inside)
      • 1e6 = Flight
  • 6m   Unknown
    • 1e   Unknown. There always seems to be a ‘!6m1!1e1’ at the end of Street View and User Photo URLs.

How these elements are used to customize Maps will be covered in subsequent posts.


Return to New Google Maps URLs introduction

Posted in Google Maps, Online Maps | Tagged , | 3 Comments

New Google Maps URLs – Latitude/Longitude in Requests

While the MAP_POSITION section must be formatted in decimal degrees, latitudes and longitudes used in place requests and directions have a lot more leeway in their formatting. For example, suppose we want to specify the point 40°07’30″N, 107°23’06″W. Some of the ways just the longitude portion can be expressed are:

107.385°W
107°23.1’W
107°23’6″W
107°23’6.0″W
107+23+6+W
-107.385
-107+23.1
-107+23’6″

The latitude and longitude directions (N/S and E/W) have to be expressed the same way, but the numeric values don’t. So while this works fine:

40.125N,+107°+23’+6.0″+W

This does not:

40.125N,-107.385

Also, Maps must be able to separate latitude from longitude. In the Western hemisphere this is not a problem, since even if the comma separator is not used, you will either have a N/S letter for latitude or a negative sign to start the longitude. In the eastern hemisphere, however, you must avoid an ambiguous location like this:

40 12 32 16

Maps cannot tell which of the following that was supposed to be:

40°12’N, 32°16’E
40°12’32″N, 16°E
40°N, 12°32’16″E

Anything that allows Maps to figure out where the separation point is will fix this; for example, all of these will work:

40 12, 32 16
40 12 N 32 16 E
40 12.0 32 16
40 12 32° 16
40 12 32 16′

However, unlike with MAP_POSITION, Maps will not be very forgiving with out-of-range values. For example, the following lat/lon:

40.125,-467.385

would be corrected to 40.125,-107.385 if used as part of a MAP_POSITION, but as a place request or directions stop it is not understood (in fact, when I tried it in directions, for some reason Maps placed that point in the North Atlantic Ocean rather than rural Colorado).


Return to New Google Maps URLs introduction

Posted in Google Maps, Online Maps | Tagged , | Leave a comment

New Google Maps URLs – Display Requests

In this post we’ll discuss the various types of DISPLAY_REQUESTplace, search, and directions requests.

Both place requests and search requests consist of their keyword followed by a slash and the description of the request:

/place/PLACE_DESCRIPTION
/search/SEARCH_DESCRIPTION

While both types are asking for map locations, place requests look for a single location while search requests look for all matching locations. As an example from my testing:

https://www.google.com/maps/search/hotels+near+Pittsburgh,+PA

centered the map just south-west of the Fort Pitt Tunnel and displayed numerous markers for area hotels. However,

https://www.google.com/maps/place/hotels+near+Pittsburgh,+PA

zoomed in on and marked only the Clarion Hotel and Conference Center in Green Tree. Changing ‘hotels’ to ‘hotel’ does not change the results. I am not sure what criteria Maps uses to determine which potentially matching location is returned.

If a search is performed for a very specific location, Maps will normally return the result as if the place keyword had been used instead (and will update the displayed URL accordingly). If a generic search term is used such as ‘hotel’, ‘restaurant’, etc., Maps will conduct its search in/near the place specified in the search or place description, or if no search location is specified it will use the default map area. Maps does not appear to distinguish between terms like ‘near’, ‘in’, ‘by’, and the like (and they can be omitted without effect). Compass directions will be treated not as directions but as place names, so asking for ‘hotels+West+of+Pittsburgh’ is likely instead to find hotels near West Homestead in the Pittsburgh area (as in my test).

Some of the common place description types are:

Full address:
/1000+Main+St,Fort+Collins,+CO
City, town, municipality, county, nation, etc.:
/Jamaica
/Denver,CO
/Potter+Twp,Beaver+County,PA
Zip/postal codes:
/80233
/L4K+5N3
Parks, landmarks, historical sites:
/Mesa+Verde+National+Park
/Gateway+Arch
Businesses, schools, museums, etc.:
/Andy+Warhol+Museum,+Pittsburgh,+PA
/Colorado+School+of+Mines
/Burkholder’s+Country+Market,+Spring+Mills,+PA
Prominent geographical features:
/Mount+Evans,+CO
/Bay+of+Fundy
Latitude/longitude coordinates:
See the post on Latitude/Longitude in Requests

Almost any term that works as a place description can be used as the place for a search (whether with the search or place keywords). However, latitude/longitude places did not work as searches in my testing; they needed to be specified in the MAP_POSITION element instead.


Unlike search and place requests, a directions request is followed by multiple terms – an origin and destination at a minimum, and potentially other intermediate estops as well:

/dir/ORIGIN/DESTINATION
/dir/ORIGIN/STOP1/STOP2/DESTINATION

The ORIGIN, DESTINATION, and intermediate stops can be anything that would work as a place description for a place or search request. Additionally, as long as Maps can identify either the ORIGIN or DESTINATION as a specific place, it will be very aggressive in interpreting any other specified stops:

This returns a result
/dir/Boston,MA/hotel/grocery+store/bowling+alley
This does not
/dir/hotel/Boston,MA/grocery+store/bowling+alley

The Maps interface will only allow you to enter ten stops (starting point, eight intermediate stops, and destination), but you can successfully enter up to 24 stops via the URL. However, unless you have a tall monitor you will probably not be able to access the details without using the ‘/am=t’ option. Adding a 25th stop will return directions, but in my testing the map itself would not load. With 26 or more stops no directions are returned and a default map is displayed.


Return to New Google Maps URLs introduction

Posted in Google Maps, Online Maps | Tagged , | Leave a comment

New Google Maps URLs – Map Positioning

When viewing a simple map (including those with place, search, or directions requests), the MAP_POSITION section is used to center the map and specify the desired zoom level. If no MAP_POSITION is specified, Maps will position the map based on the DISPLAY_REQUEST if one was specified; otherwise it will use a default location (which appears to be the user’s location, to the degree Maps can determine it).

Maps will preferentially use MAP_POSITION to center and zoom the map, even if this causes the requested place or directions to be “off-map”. Also, if a search is done with the search term specifying one location while MAP_POSITION specifies another, the map will display the results of the search in the MAP_POSITION area while the dropdown box on the left shows results from the search-specified area.


The format used for MAP_POSITION is:

/@LATITUDE,LONGITUDE,ZOOM
Example (Gateway Arch, St. Louis):
/@38.6245,-90.1849,18z

LATITUDE is expressed in decimal degrees. The map can extend from -85° to +85°, so the specified latitude cannot be a value which would cause the map to display outside that range (what that value is will depend on the zoom level and the map height). If the URL specifies a latitude outside the allowable range, Maps will move it the smallest distance towards zero necessary to make it valid.

LONGITUDE is also expressed in decimal degrees. The map extends from -180° to +180° and wraps around; if longitude is set to a value less than -180° or greater than 180°, Maps will convert it to the equivalent angle within that range (i.e., 350.2 would become -9.8).

ZOOM can be expressed either as a zoom “level”, or as the distance in meters represented by the vertical extent of the map (i.e., the distance from map bottom to map top). Zoom level is indicated by the letter ‘z’; distance in meters by the letter ‘m’.

According to my testing, zoom levels can range from 3z (maximum zoom-out) to 21z (maximum zoom-in). A level greater than 21 is treated as 21; a level less than 3 but greater than 0 is treated as 3. A level which is 0 or negative causes the position section to be ignored. A fractional level between 3 and 21 is truncated unless it is within about 0.05 of the next higher level, in which case it is rounded up. Classic Maps would allow higher zoom levels in certain areas, but my tests of a couple of these areas in new Maps shows a maximum zoom of 21.

Distances will always get rounded to the appropriate distance for a given zoom level. So, for example, if 12z is equivalent to 26211m and 11z is equivalent to 52422m, you can’t use 37068m to get the equivalent of 11.5z; it will automatically get rounded out to 52422m/11z. However, if the distance were within about 3.53% of the lower value, it would get rounded down (in this example, 27135m would round in to 26211m/12z, but 27136m would round out to 52422m/11z).

By default, Maps uses zoom levels for street maps and distance in meters for satellite view, but the URL will accept either form for either type of map.


When viewing a Street View image, the MAP_POSITION section has a different format:

/@LATITUDE,LONGITUDE,3a,FOCUS,DIRECTION,ANGLE
Example (Top of Gateway Arch viewed from Leonor K Sullivan Blvd):
/@38.624468,-90.183907,3a,75y,280.72h,152.73t

LATITUDE and LONGITUDE are the same as described above for simple maps.

3a just is. I have never seen anything else here, and when I’ve attempted to use other values they have either caused problems or been changed back to ‘3a’ by Maps.

FOCUS is like a zoom level. It can range from a maximum zoom-in of 15y to a maximum zoom-out of 90y; Street View normally starts at 75y. While the map controls will set this in multiples of 15, any value between 15 and 90 can be set in the URL and it will only be rounded to the nearest 0.1 (so, 15.5y zooms out just a touch compared to 15y). Setting the value outside the range of 0-180 produces an “invalid” image; 0-15 is treated as 15 and 90-180 is treated as 90. I do not know what the numbers represent specifically.

DIRECTION is the compass direction in degrees that the camera viewpoint is pointing in. 0 is North, 90 is East, and so on. Values are rounded to the nearest 0.01 degrees. Setting the value outside the range 0-360 produces an invalid image.

ANGLE is the elevation angle of the camera. 0 is pointing straight down, 180 is pointing straight up. Values are rounded to the nearest 0.01 degrees. Setting the value outside the range 0-180 produces an invalid image.


Return to New Google Maps URLs introduction

Posted in Google Maps, Online Maps | Tagged , | Leave a comment

New Google Maps URLs – Introduction

Google recently changed the whole look, feel and functionality of Google Maps to a new format, and has phased out the old Classic Maps pretty much completely. Frankly, given how close to perfect Classic Maps were, and how inferior the new version is, this seems a lot like Coca-Cola’s rollout of New Coke many years ago – except that Google’s not likely to backtrack the way Coca-Cola did. So, time to bite the bullet and start decoding the new system.

One of the many things that changed drastically is the URL format, and that’s what I will be exploring in this series of posts. This post will describe the general format of the Maps URL and provide a hyperlinked index of all subsequent posts for easy reference (items below which are not hyperlinks designate posts not yet made/completed).

Note that this will undoubtedly be a continual work-in-progress. Existing posts will be updated whenever I find new information; new posts will be added whenever called for.


Google Maps URLs all have the following ‘root’:

https://www.google.com/maps

Entering this alone will bring up a map centered at a default location and zoom level (which are apparently determined by how accurately Maps can determine your location). There are four types of sections which can be appended to this root URL (NOTE: the section names are mine; I have no idea what Google might call them):

DISPLAY_REQUEST – Specifies what the user wants to see displayed on the map. /search/… requests locations matching a set of search terms; /place/… requests a single, specific location; /dir/… requests a set of travel directions. These are covered in more detail in the Display Requests post.

MAP_POSITION – For regular maps, this specifies where the map is to positioned, and at what zoom level. For Street View, it specifies camera location, zoom and positioning. This section is described in detail in the Map Positioning post.

DETAIL_BOX – The only example I have seen of this section is /am=t. It causes the box with driving route details to appear if a set of directions has been requested which has no missing stops; otherwise it has no effect.

DATA_OPTIONS – Specifies additional clarifications to the request made and/or display parameters. All available options which I have identified are listed in the Data Options Reference post, and many are explained in more detail in the various posts which follow it.

These four sections may appear in any order, except that the DETAIL_BOX and DATA_OPTIONS sections cannot appear first in order. By default, Maps will put them in the same order that I have listed them above. Also, you should note that if you enter a URL that is not in the form that Maps would produce, Maps will rearrange and restructure it, including adding any “missing” elements. Occasionally this will result in a URL which will not reproduce the same map or view (I will try to note these situations in the relevant posts, where applicable).


These are the posts with more detailed information about the new Maps URL format:

Posted in Google Maps, Online Maps | Tagged , | 2 Comments