O'Reilly logo

QGIS Blueprints by Ben Mearns

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

  1. Open the qgis2leaf Export dialog (navigate to Web | qgis2leaf | Exports).
  2. 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.
  3. Take note of the output location.
  4. Click on OK.
  5. Locate index.html in the output directory.
  6. Replace the contents of index.html with the following code (also available at c3/data/web/index.html ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required