Page Summary
-
The
heatmapTilesendpoint delivers air quality heatmaps as a tile overlay, which is a collection of PNG images displayed on top of a Google Map. -
Each tile within the overlay has specific (X, Y) coordinates, with (0,0) at the northwest corner and increasing values eastward (X) and southward (Y), determined by the zoom level.
-
The zoom level (0-16) controls the map's scale and the tile grid size, with higher zoom levels showing more detailed areas.
-
To request a heatmap tile, you need to provide the heatmap type, zoom level (Z), tile coordinates (X, Y), and your API key in the request URL.
-
You can overlay these heatmap tiles on top of the default map using methods described in the provided documentation for a comprehensive air quality visualization.
The
heatmapTiles
endpoint provides air quality related heatmaps through a tile overlay. A tile
overlay is a collection of PNG image tiles that can be displayed on top of a
Google Maps. Each image tile is (256 x 256 pixels).
About heatmap tiles
The tile overlay is a grid assembled from a collection of tiles,
each assigned (X,Y) coordinates.
The tile with coordinates (0,0) is always at the northwest corner
of the map. The X values increase from west to east,
while the Y values increase from north to south.
The zoom level determines how large or small the contents of a map appear in a
map view. The tile grid size is determined by scaling the X and Y
coordinates exponentially by the zoom level.
gridSizeX = XzoomLevel gridSizeY = YzoomLevel
For example, at a zoom level of 2, the world map is represented using a 4 x 4 matrix, for a total of 16 tiles. The zoom also determines what is the max value allowed for the coordinates.
The following image shows a US_AQI heatmap with a zoom level of 2,
along with the coordinates of each tile:
See Map and Tile coordinates for additional details.
About the heatmap endpoint
A heatmap tile is represented by a bytes array containing the tile data as a PNG
image. You request current air quality heatmap tiles using the
heatmapTiles
endpoint by sending an HTTP GET request to:
https://airquality.googleapis.com/v1/mapTypes/TYPE/heatmapTiles/Z/X/Y?key=YOUR_API_KEY
All request parameters are required in a request:
TYPE- The type heatmap to return. See allowed values.Z- Zoom level that determines how large or small the contents of a map appear in a map view. Allowed values are 0-16, where a value of 0 displays the entire world in a single tile.X,Y- The coordinates of the tile to retrieve, relative to the north west corner (0,0).Xvalues are increasing from west to east andYvalues are increasing from north to south.Tile coordinates have to be valid for the specified zoom level. For example, if you set the zoom level to 2, and request a tile at coordinates of 10,10, the API returns an error.
YOUR_API_KEY- Your application's API key. This key identifies your application for purposes of quota management. For more information, see get a key. To load tiles in a web app, see Display heatmap tiles on a web map.
Example heatmap request
The image above shows a US_AQI heatmap with a zoom level of 2,
along with the coordinates of each tile. The following example uses the
heatmapTiles endpoint to request the tile at coordinates 0,1 from the
heatmap:
https://airquality.googleapis.com/v1/mapTypes/US_AQI/heatmapTiles/2/0/1?key=YOUR_API_KEY
The tile appears as:

Display heatmap tiles on a web map
To overlay Air Quality API tiles from the
heatmapTiles endpoint on a Maps JavaScript API map,
pass a getTileUrl function to
google.maps.ImageMapType and insert the layer into
map.overlayMapTypes.
Route tile requests through a backend proxy so your Air Quality API credentials (an IP addresses-restricted API key or an OAuth token) stay on your server:
- Authenticate and rate-limit callers: Require caller authentication and rate limiting on your proxy route so external users can't abuse your project's quota.
- Validate route parameters: Allowlist
mapTypeagainst supportedMapTypevalues and parsezoom(0to16) andx/y(0to2^zoom - 1) as integers to prevent path traversal. - Fetch tiles from the server: Request the PNG from
airquality.googleapis.comusing anX-Goog-Api-Keyheader or OAuth headers, and return the image bytes to the browser. See Use a proxy server.
The following example loads a US_AQI overlay through a backend tile proxy. It
wraps coord.x horizontally and returns null when zoom or coord.y is
outside the supported tile range:
const {Size} = await google.maps.importLibrary("core");
const {ImageMapType} = await google.maps.importLibrary("maps");
const airQualityTiles = new ImageMapType({
getTileUrl(coord, zoom) {
if (zoom < 0 || zoom > 16) return null;
const maxTile = 1 << zoom;
if (coord.y < 0 || coord.y >= maxTile) return null;
const x = ((coord.x % maxTile) + maxTile) % maxTile;
return `/api/air-quality/tiles/US_AQI/${zoom}/${x}/${coord.y}`;
},
tileSize: new Size(256, 256),
opacity: 0.6,
});
map.overlayMapTypes.insertAt(0, airQualityTiles);
Display the required attribution when showing Air Quality API imagery. For more information about custom tile layers, see Image Map Types and Overlay Map Types.
Common mistakes when loading heatmap tiles
- Exposing a server API key in browser tile URLs: Putting a
Air Quality API key in client-side
heatmapTilesURLs exposes credentials in browser network traffic and breaks IP addresses restrictions. Keep credentials on your backend proxy and set per-day and per-user quota limits (which default to unlimited). - Passing unnormalized
ImageMapTypecoordinates: Panning past the antimeridian or poles or zooming past level 16 sends out-of-range coordinates or zoom values (400 Bad Request). Wrapcoord.xand returnnullwhencoord.yorzoomis out of bounds.