
Publishing the results as a web application
Now that we have completed our modeling for the site selection of a farmland for conservation, let's take steps to publish this for the Web.
qgis2leaf
qgis2leaf allows us to export our QGIS map to web map formats (JavaScript, HTML, and CSS) using the Leaflet map API. Leaflet is a very lightweight, extensible, and responsive (and trendy) web mapping interface.
qgis2leaf converts all our vector layers to GeoJSON, which is the most common textual way to express the geographic JavaScript objects. As our operational layer is in GeoJSON, Leaflet's click interaction is supported, and we can access the information in the layers by clicking. It is a fully editable HTML and JavaScript file. You can customize and upload it to an accessible web location, as you'll understand in subsequent chapters.
qgis2leaf is very simple to use as long as the layers are prepared properly (for example, with respect to CRS) up to this point. It is also very powerful in creating a good starting application including GeoJSON, HTML, and JavaScript for our Leaflet web map. Perform the following steps:
- Make sure to install the qgis2leaf plugin if you haven't already.
- Navigate to Web | qgis2leaf | Exports a QGIS Project to a working Leaflet webmap.
- Click on the Get Layers button to add the currently displayed layers to the set that qgis2leaf will export.
- Choose a basemap and enter the additional details if so desired.
- Select Encode to JSON.
These steps will produce a map application similar to the following one. We'll take a look at how to restore the labels in the next chapter:
