Leaflet and an external API: CartoDB SQL
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.
- Locate
index.html
in the output directory. - Replace the contents of
index.html
with the following code (also available atc3/data/web/index.html ...
Get QGIS: Becoming a GIS Power User now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.