In the first section, we created a web application using Leaflet and the local GeoJSON files containing our layers. In this section, we will use Leaflet to display data from an external API—CartoDB SQL API. Perform the following steps:
Open the qgis2leaf Export dialog (navigate to Web | qgis2leaf | Exports).
In the qgis2leaf dialog, you can leave the inputs as their default ones. We will be heavily modifying the output code, so this part isn't so important. You may wish to add a basemap; MapQuest Open OSM is a good choice for this.
Take note of the output location.
Click on OK.
index.htmlin the output directory.
Replace the contents of
index.htmlwith the following code (also available at
c3/data/web/index.html). This code is identical to the existing
index.htmlwith a few modifications. All lines after 25 and the ones below the closing script, body, and HTML tags have been removed. The
getToxicfunction and call have been added. Look for this function...