Embed the real-time air quality map on your website

Share: aqicn.org/maplet/

The real-time air quality map of the World Air Quality Index project can be embedded on any website with a single script tag. The map shows the live Air Quality Index of all the monitoring stations around the selected location, and is updated automatically.

Copy the code below where the map should appear on your page:

<script src="https://aqicn.org/maplet/embed.v1.js"
        data-city="london"
        data-lat="51.5074" data-lng="-0.1278" data-zoom="11"
        data-height="450"></script>

Result (move or zoom the map to update the code above):

Asynchronous loading

To avoid delaying the rendering of your page, the script can be loaded asynchronously, with the async or defer attribute. Since the script then does not run at its position in the page, the data-dom-target attribute is required to specify the element in which the map is inserted. The element can be placed anywhere in the page, before or after the script tag.

<div id="aqi-map"></div>

<script async src="https://aqicn.org/maplet/embed.v1.js"
        data-city="paris"
        data-dom-target="aqi-map"
        data-height="450"></script>

Result:

Loading the script from javascript

The script can also be inserted dynamically, for instance from a tag manager or a single page application. The same data-dom-target rule applies:

<div id="aqi-map"></div>

<script>
  var s = document.createElement("script");
  s.src = "https://aqicn.org/maplet/embed.v1.js";
  s.setAttribute("data-city", "london");
  s.setAttribute("data-dom-target", "aqi-map");
  document.head.appendChild(s);
</script>

Options

The map is configured with the following attributes of the script tag. They are all optional, except data-dom-target for asynchronous loading.

AttributeDescriptionDefault
data-cityLocation to show: a city, region or country, eg london, paris, beijing, greece.world
data-lat
data-lng
Latitude and longitude of the center of the map. Both are needed to set an explicit view.center of the location
data-zoomZoom level, from 1 (world) to 18 (street). Only used with data-lat and data-lng.11
data-langLanguage of the map, eg fr, es, de, cn, jp, kr.english
data-widthWidth of the map: a number (pixels) or a css size such as 600px or 100%.100%
data-heightHeight of the map: a number (pixels) or a css size such as 450px or 60vh.450px
data-dom-targetId (or css selector) of the element in which the map is inserted. Required when the script is loaded asynchronously (async, defer or inserted dynamically). Without it, the map is inserted right after the script tag.–

Several maps can be embedded on the same page: use one script tag per map.

Build your map

Fill in the options below to get the code for your map, and preview it.

Good to know

  • Links in the map (eg station details) open in a new tab, so that visitors do not leave your page.
  • The map can be embedded on any website served over http or https. It can not be displayed from a page opened as a local file (file://).
  • If the map is placed in a sandboxed iframe, the sandbox must at least allow allow-scripts allow-same-origin allow-popups.
  • Please do not remove or hide the attribution to the World Air Quality Index project and to the data sources.

Using an iframe directly

If you can not add scripts to your page, the map can also be embedded with a plain iframe. The location is part of the url, and the view is set with the lat, lng and zoom parameters:

<iframe src="https://aqicn.org/maplet/london/?lat=51.5074&lng=-0.1278&zoom=11"
        width="100%" height="450" style="border:0" loading="lazy"
        title="Real-time air quality map"></iframe>

About the Air Quality and Pollution Measurement:

About the Air Quality Levels

AQIAir Pollution LevelHealth ImplicationsCautionary Statement (for PM2.5)
0 - 50GoodAir quality is considered satisfactory, and air pollution poses little or no riskNone
51 -100ModerateAir quality is acceptable; however, for some pollutants there may be a moderate health concern for a very small number of people who are unusually sensitive to air pollution.Active children and adults, and people with respiratory disease, such as asthma, should limit prolonged outdoor exertion.
101-150Unhealthy for Sensitive GroupsMembers of sensitive groups may experience health effects. The general public is not likely to be affected.Active children and adults, and people with respiratory disease, such as asthma, should limit prolonged outdoor exertion.
151-200UnhealthyEveryone may begin to experience health effects; members of sensitive groups may experience more serious health effectsActive children and adults, and people with respiratory disease, such as asthma, should avoid prolonged outdoor exertion; everyone else, especially children, should limit prolonged outdoor exertion
201-300Very UnhealthyHealth warnings of emergency conditions. The entire population is more likely to be affected.Active children and adults, and people with respiratory disease, such as asthma, should avoid all outdoor exertion; everyone else, especially children, should limit outdoor exertion.
300+HazardousHealth alert: everyone may experience more serious health effectsEveryone should avoid all outdoor exertion

To know more about Air Quality and Pollution, check the wikipedia Air Quality topic or the airnow guide to Air Quality and Your Health.

For very useful health advices of Beijing Doctor Richard Saint Cyr MD, check www.myhealthbeijing.com blog.


Usage Notice: All the Air Quality data are unvalidated at the time of publication, and due to quality assurance these data may be amended, without notice, at any time. The World Air Quality Index project has exercised all reasonable skill and care in compiling the contents of this information and under no circumstances will the World Air Quality Index project team or its agents be liable in contract, tort or otherwise for any loss, injury or damage arising directly or indirectly from the supply of this data.