Skip to content

A QGIS plugin to export a map to an OpenLayers 3/Leaflet webmap

License

Notifications You must be signed in to change notification settings

walkermatt/qgis2web

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage Status Join the chat at https://gitter.im/tomchadwin/qgis2web

qgis2web

QGIS plugin to export your project to an OpenLayers 3 or Leaflet webmap. No server-side software required.

Installation

  • In QGIS, select Plugins > Manage and Install Plugins...

or:

  • Download and unzip to your QGIS plugins directory

Usage

Prepare your map as far as possible in QGIS, as you want it to appear in your webmap. Specific tasks you can carry out to improve your webmap include:

  • Set your project title, and background and highlight colours in Project > Project Properties...
  • Give your layers human-friendly names in the Layers Panel
  • Give your layer columns human friendly names via Layer > Properties > Fields > Alias
  • Hide the columns you don't want to appear in your popups by changing their Edit widget to "Hidden"
  • Style your layers, and set their scale-dependent visibility, if required

Run qgis2web from the Web menu, or via its icon. If required, choose a basemap from the list below the preview pane, and click "Update preview". CTRL/CMD-click for multiple basemaps or to deselect a basemap.

The top-left pane lets you set options for each layer in your map. The bottom-left pane sets overall options. All options are written to your QGIS project, so save your proejct if you want to keep these settings.

Current limitations

QGIS, OpenLayers 3, and Leaflet are all different mapping technologies. This means that their respective functionality differs in many ways. qgis2web does its best to interpret a QGIS project and to export HTML, Javascript, and CSS to create a web map as close to the QGIS project as possible.

However, many elements of a QGIS project cannot be reproduced, and many are only possible in either OpenLayers 3 or Leaflet. qgis2web tries its best to produce a publish-ready map, but you can always manually edit the output code to achieve what qgis2web cannot.

  • no rule-based rendering
  • SVG point markers sometimes do not appear in the preview pane, but work when the map is exported
  • Leaflet maps only use each symbol's first symbol layer
  • in OL3 maps, only single rendered points cluster, not categorized or graduated
  • rasters are exported unstyled
  • line style (dashed/dotted) does not appear in OL3 preview, but works in export
  • Leaflet cannot label lines and polygons, only points
  • only a single 2.5d layer will render per map
  • 2.5d layers only appear when zoomed in to building scales

Layer options

Info popup content
Select which fields will appear in popups when features are clicked
Visible
Select whether the layer will be visible on map load. This only determines visibility - the layer will be loaded regardless of this setting
Encode to JSON
If unchecked, WFS layers will remain remote WFS layers in the webmap. If checked, the layer will be written to a local GeoJSON file
Cluster
Cluster point features

General options

Data export

Delete unused fields
If "show all attrubutes" is not selected in "Info popup content", remove the undisplayed fields from the GeoJSON - helps to reduce file size
Export folder
The folder where the webmap will be saved
Mapping library location
Select whether to use a local copy of OL3/Leaflet, or whether to call the library from its CDN
Minify GeoJSON files
Remove unnecessary whitespace from exported GeoJSON to reduce file size
Precision
Simplify geometry to reduce file size

Scale/Zoom

Extent
Either match the current QGIS view or show all contents of all layers (only local GeoJSON and rasters, not WFS/WMS)
Max zoom level
How far the webmap will zoom in
Min zoom level
How far the webmap will zoom out
Restrict to extent
Prevent panning or zooming beyond the selected extent

Appearance

Add address search
Add field to allow searching for locations (geocode)
Add layers list
Include list of layers (with legend icons, where possible)
Add measure tool
Include interactive measuring widget
Add scale bar
Include dynamic scale bar
Geolocate user
Show user's location on map
Highlight on hover
Highlight features on mouseover
Match project CRS
Create webmap in same projection as QGIS project, otherwise the webmap is projected in EPSG:3857
Show popups on hover
Show popups when mouse hovers over features
Template
Select HTML template for webmap - add your own templates to the /qgis2web/templates directory in your .qgis2 folder

Reporting bugs

Please report any problems you have with qgis2web. Without this feedback, I am often completely unaware that a problem exists. To ensure no time or effort is wasted in bug reporting, please follow these steps:

  1. Make sure you are using the latest release of qgis2web
  2. Check the issues on Github to see whether the bug has already been reported, and if so, read through all the comments on the issue, and add any additional informaton from your experience of the bug
  3. Make sure you can reproduce the bug reliably
  4. Reduce the complexity of your bug conditions as far as you can, especially by reducing the number of layers, ideally to one
  5. Raise a Github issue, including:
    • the qgis2web version (or make it clear you are using Github master branch)
    • any Python error text/stack trace which occurs
    • browser JS console errors - press F12 in qgis2web to open the developer toolbar and find the console
    • screenshot of your settings
    • screenshot of the output
    • a link to the data you used, if possible

The stability of qgis2web relies on your bug reports, so please keep them coming.

Development

qgis2web is largely developed by me, with significant contribtions from a few others. Please, please do contribute, as there is so much more to do.

As for the overall direction of the plugin, there is now basically feature parity between Leaflet and OL3 exports. Any new features should be implemented in both formats, or I am not keen for it to be included.

The core philosophy of the plugin is: don’t get the plugin to do anything which QGIS can already do. Also, keep focused on producing good-quality maps, reproducing as much from QGIS as possible, rather than adding extra new functionality.

Coding guidelines:

  • Comply with PEP8
  • Remove print statements before making a pull request
  • Don’t break the tests themselves (all in test/test_qgis2web_dialog.py)
  • Anything which alters the output for the basic tests will mean updating the control files in /test/data/control
  • Write tests for new functionality
  • Don't introduce a new client-side library for something which can easily be done without it (I'm looking at you, jQuery)

Other improvements required are:

  • Improve code quality/refactor
  • Write tests for more functionality - coverage is currently very low

Testing

All commits and PRs are tested by Travis. The tests are in /test, specifically /test/ test_qgis2web_dialog.py. If you want to run these tests locally on Linux, do the following to prepare:

apt-get install python-pip
pip install nose
cd ~/.qgis2/python/plugins/qgis2web
source scripts/run-env-linux.sh [/path/to/qgis/installation]

Run the tests with make test.

Untested functionality includes:

  • rasters
  • labels
  • rule-based renderer
  • SVG markers
  • polygon border style "No pen"
  • polygon fill style "No brush"
  • line cap/join styles
  • change export folder via mouse click
  • save settings
  • click layer popup combo
  • unchecked layers initially collapsed and non-visible
  • restore saved project/layer settings
  • open dev console
  • WFS encode to JSON
  • close qgis2web
  • Leaflet polygon outline: simple line
  • Leaflet line style (dot/dash)
  • Leaflet line width > 1
  • Leaflet categorized clusters
  • Leaflet graduated clusters
  • Leaflet WMS
  • Leaflet WFS clusters
  • Leaflet JSON non-point popups
  • Leaflet scale-dependent visibility
  • Leaflet match CRS
  • Leaflet basemaps
  • Leaflet basemaps + layers list
  • Leaflet cluster + layers list
  • Leaflet raster + layers list
  • Leaflet project title
  • Leaflet highlight + popups on hover
  • Leaflet categorized on non-string column
  • Leaflet categorized JSON point without popup
  • Leaflet custom popup contents via html_prov
  • Leaflet export
  • OL3 measure - imperial units
  • OL3 blank template value
  • OL3 layer groups
  • OL3 canvas extent
  • OL3 WFS cluster
  • OL3 layer transparency

If anyone has time to write tests for any of this, it will benefit the plugin hugely. If you do, make sure you delete the tests from this list. Some of the items above I don't even know how to test...

Credits

qgis2web is fundamentally a merge of Victor Olaya's qgis-ol3 and Riccardo Klinger's qgis2leaf. It would not exist without their work. Thank you, gentlemen. Thanks are also very much due to Paolo Cavallini, who suggested and supported the merge.

  • @volaya
  • @riccardoklinger
  • @pcav

Obviously, qgis2web could not exist without the following monumental software:

  • QGIS
  • OpenLayers 3
  • Leaflet

Thanks are also due for major code contributions to:

  • @akbargumbira
  • @lucacasagrande
  • @walkermatt
  • @boesiii

In addition, the following libraries have been used:

  • ol3-layerswitcher, by @walkermatt
  • Autolinker.js, by @gregjacobs
  • requestAnimationFrame polyfill, by @paulirish
  • Function.prototype.bind polyfill, by @mozilla
  • Leaflet.draw, by @jacobtoye
  • Leaflet.label, by @jacobtoye
  • Leaflet.markercluster, by @danzel
  • Leaflet.MeasureControl, by @makinacorpus
  • leaflet-hash, by @mlevans
  • Proj4js, by @madair, @calvinmetcalf, and other
  • Proj4Leaflet, by @kartena
  • OSMBuildings, by @kekscom

About

A QGIS plugin to export a map to an OpenLayers 3/Leaflet webmap

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 41.3%
  • QML 27.6%
  • HTML 17.8%
  • JavaScript 11.0%
  • CSS 1.5%
  • Makefile 0.6%
  • Shell 0.2%