Advertisements

Quick webmaps with qgis2web

In Publishing interactive web maps using QGIS, I presented two plugins for exporting web maps from QGIS. Today, I want to add an new member to this family: the qgis2web plugin is the successor of qgis-ol3 and combines exports to both OpenLayers3 as well as Leaflet.

The plugin is under active development and currently not all features are supported for both OpenLayers3 and Leaflet, but it’s a very convenient way to kick-off a quick webmapping project.

Here’s an example of an OpenLayers3 preview with enabled popups:

OpenLayers3 preview

OpenLayers3 preview

And here is the same map in Leaflet with the added bonus of a nice address search bar which can be added automatically as well:

Leaflet preview

Leaflet preview

The workflow is really straight forward: select the desired layers and popup settings, pick some appearance extras, and then don’t forget to hit the Update preview button otherwise you might be wondering why nothing happens ;)

I’ll continue testing these plugins and am looking forward to seeing what features the future will bring.

Advertisements
29 comments
  1. Thanks, Anita. Trying to push for a 1.0.0 release, though there’s still a lot to do for that milestone…

  2. We can also add Lizmap (https://github.com/3liz) which is less straightforward because you need to install a server’s side part but there are more features (e.g. you can edit your data via WFS, print maps in PDF, it handles cache…). The doc is here http://docs.3liz.com//en/

    • Thanks! Do you mean that you’d be interested in integrating LIzmap export into qgis2web?

  3. Sorry I misspoke. I mean, Lizmap can be added to the list of quick webmaps tools.

  4. azolnai57 said:

    Luv ur posts Anita! Have you looked @ qgiscloud.com or does that not fall under this theme? Cheers, Andrew

    • Hi Andrew,
      QGISCloud is similar but different :) There, the user publishes to a QGIS Server instance which is hosted by Sourcepole. The other plugins I presented in this series create stand-alone web maps which can be hosted on any web server. But of course it’s a very similar theme.

  5. Do I have to install any software or can I use this right out of the Plugin repo? I keep getting blank maps (source code seems good). Now I’m getting error messages referring to Python errors such as:

    qgis2web produced an error:

    Traceback (most recent call last):
    File “C:/Users/Jerry/.qgis2/python/plugins\qgis2web\maindialog.py”, line 115, in previewMap
    MainDialog.previewLeaflet(self)
    File “C:/Users/Jerry/.qgis2/python/plugins\qgis2web\maindialog.py”, line 291, in previewLeaflet
    json, params, popup)
    File “C:/Users/Jerry/.qgis2/python/plugins\qgis2web\leafletWriter.py”, line 102, in writeLeaflet
    cleanedLayer = writeTmpLayer(i, eachPopup)
    File “C:/Users/Jerry/.qgis2/python/plugins\qgis2web\utils.py”, line 62, in writeTmpLayer
    uri = TYPE_MAP[layer.wkbType()]
    KeyError: 100

    Any help would be tremendous! Thanks very much.

    • You don’t need to install anything. For support, it’s better if you get in touch with the developer on the plugin Github page.

      • Cool thanks. I did learn if I changed the base map or the canvas/layer extent it did process. Happy Thanksgiving :)

      • Sorry it’s not been working as well as it should. If you can upload your source data somewhere for me to test, and tell me your settings, I can take a look at it.

      • Hi Tom – I put a semi-working leaflet version here: enjoypb.com/temp/qgis2web_1448427533.21/index.html – I now know I’ll have to do a number of things to add labels and other functions. I tried an OSM version and lost different feature settings but, can work on that too. That sample is here: enjoypb.com/temp/qgis2web_2015_11_25_09_42_26/index.html
        Thanks for any guidance.

      • It’s the source layer I need. Can you upload that?

      • Jerry Hall said:

        Is there any place I can connect with you outside of this forum Tom? Thanks.

  6. Hi Tom, Could you check the zip in the same directory? I put the .prjs (because the datasets are huge) and the project page. I also put the fixes for the maindialog and utils pages but, the utils page code didn’t match with the version I have and the fix in Github. Thanks!

    • Which version of qgis2web do you have installed? The fix I linked to is from a good while back. If you are using the latest release, you’ll have that fix already.

      When I’m at my desk tomorrow, I’ll figure out a console command for you to type which will help us figure out what geometry type the layer is. As I say, that seems to be causing some of the problem.

  7. I found the CRS and changed for the three layers (to: NAD_1983_StatePlane_California_VI_FIPS_0406_Feet) and made that the setting for the one data layer that reflects polygons in my CSV.

    I have 0.35 installed. I uninstalled and reinstalled and get the same utils.py file that doesn’t match the code in the commit here: https://github.com/tomchadwin/qgis2web/commit/14b8dcb179ff81f95593ee84eeeb31be69c7371a. I did make the first edit in the maindialog.py file. I then tried to export a leaflet map and got this:

    Traceback (most recent call last):
    File “C:/Users/Jerry/.qgis2/python/plugins\qgis2web\maindialog.py”, line 130, in saveMap
    if self.mapFormat.checkedButton().text() == “OpenLayers 3”:
    File “C:/Users/Jerry/.qgis2/python/plugins\qgis2web\maindialog.py”, line 312, in saveLeaf
    json, cluster, labels) = self.getLayersAndGroups()
    File “C:/Users/Jerry/.qgis2/python/plugins\qgis2web\leafletWriter.py”, line 234, in writeLeaflet
    json, wfsLayers)
    File “C:/Users/Jerry/.qgis2/python/plugins\qgis2web\leafletWriter.py”, line 647, in categorizedLayer
    json, count, popFuncs, wfsLayers)
    File “C:/Users/Jerry/.qgis2/python/plugins\qgis2web\leafletWriter.py”, line 744, in categorizedPolygon
    border_transp = float(symbolLayer.borderColor().alpha()) / 255
    AttributeError: ‘QgsSimpleLineSymbolLayerV2’ object has no attribute ‘borderColor’

    Python version:
    2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)]

    QGIS version:
    2.8.2-Wien Wien, 1b929ef

    Python path: [‘C:/Users/Jerry/.qgis2/python/plugins\\processing’, ‘C:/PROGRA~1/QGISWI~1/apps/qgis/./python’, u’C:/Users/Jerry/.qgis2/python’, u’C:/Users/Jerry/.qgis2/python/plugins’, ‘C:/PROGRA~1/QGISWI~1/apps/qgis/./python/plugins’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\matplotlib-1.3.1-py2.7-win-amd64.egg’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\nose-1.3.3-py2.7.egg’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\tornado-4.0.1-py2.7-win-amd64.egg’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\backports.ssl_match_hostname-3.4.0.2-py2.7.egg’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\certifi-14.05.14-py2.7.egg’, ‘C:\\PROGRA~1\\QGISWI~1\\bin\\python27.zip’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\DLLs’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\plat-win’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\lib-tk’, ‘C:\\PROGRA~1\\QGISWI~1\\bin’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\PIL’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\jinja2-2.7.2-py2.7.egg’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\markupsafe-0.23-py2.7-win-amd64.egg’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\pytz-2012j-py2.7.egg’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\win32’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\win32\\lib’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\Pythonwin’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\Shapely-1.2.18-py2.7-win-amd64.egg’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\six-1.3.0-py2.7.egg’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\wx-2.8-msw-unicode’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\xlrd-0.9.2-py2.7.egg’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\xlwt-0.7.5-py2.7.egg’, u’C:/Users/Jerry/.qgis2//python’, ‘C:\\Users\\Jerry\\.qgis2\\python\\plugins’, ‘C:\\Users\\Jerry\\.qgis2\\python\\plugins\\SelectTools/tools’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\qgis\\python\\plugins\\fTools\\tools’, ‘C:\\Users\\Jerry\\.qgis2\\python\\plugins’, ‘C:/Users/Jerry/Dropbox/_civicarchive/_client-user leads/david allen/civicsd/2014-2015 project lists/2014-15_map/gisData’]

    Thanks again.

  8. The problem seems to be that the plugin is trying to render a layer with no geometry (WKBType 100 from your first error). Layers with no geometry should not make it into the plugin layer list, so I’m not sure how that is happening.

    Are you able to narrow down the issue to a single layer which causes the problem? If so, and you can send me that layer, it will help in diagnosing the issue.

    Also, I think I have simply confused matters by linking to the former commit for a similar issue. I wasn’t asking you to change the plugin code at all, and suspect that the changes you’ve now made might not have helped. Can you reinstall either from the QGIS plugins repo or from Github? We can then confirm what the issue is.

    • Hey Tom I reinstalled the plugin and have tried pinpointing this issue. The OSM seems to work better. It triggers a few alerts about broken scripts but, gives a workable map. The only big issue there is the Null value is appearing on the first two (projectsandstatus and projectsandstatusnumbers) layers in a large quantity. Is there a way to prevent display of Null values?

      For the Leaflet map, which I would prefer so I can use and tweak it more I’m getting this message below.

      I uploaded both in the same directory (and put the others in the archive). Thanks for any help you can give.

      Thanks!

      An error has occured while executing Python code:

      Traceback (most recent call last):
      File “C:/Users/Jerry/.qgis2/python/plugins\qgis2web\maindialog.py”, line 130, in saveMap
      MainDialog.saveLeaf(self)
      File “C:/Users/Jerry/.qgis2/python/plugins\qgis2web\maindialog.py”, line 312, in saveLeaf
      json, params, popup)
      File “C:/Users/Jerry/.qgis2/python/plugins\qgis2web\leafletWriter.py”, line 234, in writeLeaflet
      json, wfsLayers)
      File “C:/Users/Jerry/.qgis2/python/plugins\qgis2web\leafletWriter.py”, line 647, in categorizedLayer
      json, count, popFuncs, wfsLayers)
      File “C:/Users/Jerry/.qgis2/python/plugins\qgis2web\leafletWriter.py”, line 744, in categorizedPolygon
      border_transp = float(symbolLayer.borderColor().alpha()) / 255
      AttributeError: ‘QgsSimpleLineSymbolLayerV2’ object has no attribute ‘borderColor’

      Python version:
      2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)]

      QGIS version:
      2.8.2-Wien Wien, 1b929ef

      Python path: [‘C:/Users/Jerry/.qgis2/python/plugins\\processing’, ‘C:/PROGRA~1/QGISWI~1/apps/qgis/./python’, u’C:/Users/Jerry/.qgis2/python’, u’C:/Users/Jerry/.qgis2/python/plugins’, ‘C:/PROGRA~1/QGISWI~1/apps/qgis/./python/plugins’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\matplotlib-1.3.1-py2.7-win-amd64.egg’, ‘C:\\Users\\Jerry\\.qgis2\\python\\plugins\\opengeo\\ext-libs\\requests-2.0.1-py2.7.egg’, ‘C:\\Users\\Jerry\\.qgis2\\python\\plugins\\opengeo\\ext-libs\\python_dateutil-2.2-py2.7.egg’, ‘C:\\Users\\Jerry\\.qgis2\\python\\plugins\\opengeo\\ext-libs\\six-1.9.0-py2.7.egg’, ‘C:\\Users\\Jerry\\.qgis2\\python\\plugins\\opengeo\\ext-libs\\lxml-3.3.5-py2.7-win32.egg’, ‘C:\\Users\\Jerry\\.qgis2\\python\\plugins\\opengeo\\ext-libs\\gsimporter-0.2-py2.7.egg’, ‘C:\\Users\\Jerry\\.qgis2\\python\\plugins\\opengeo\\ext-libs\\httplib2-0.9-py2.7.egg’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\nose-1.3.3-py2.7.egg’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\tornado-4.0.1-py2.7-win-amd64.egg’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\backports.ssl_match_hostname-3.4.0.2-py2.7.egg’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\certifi-14.05.14-py2.7.egg’, ‘C:\\PROGRA~1\\QGISWI~1\\bin\\python27.zip’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\DLLs’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\plat-win’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\lib-tk’, ‘C:\\PROGRA~1\\QGISWI~1\\bin’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\PIL’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\jinja2-2.7.2-py2.7.egg’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\markupsafe-0.23-py2.7-win-amd64.egg’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\pytz-2012j-py2.7.egg’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\win32’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\win32\\lib’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\Pythonwin’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\Shapely-1.2.18-py2.7-win-amd64.egg’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\six-1.3.0-py2.7.egg’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\wx-2.8-msw-unicode’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\xlrd-0.9.2-py2.7.egg’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\xlwt-0.7.5-py2.7.egg’, u’C:/Users/Jerry/.qgis2//python’, ‘C:\\Users\\Jerry\\.qgis2\\python\\plugins\\opengeo\\ext-libs’, ‘C:\\Users\\Jerry\\.qgis2\\python\\plugins’, ‘C:\\Users\\Jerry\\.qgis2\\python\\plugins\\SelectTools/tools’, ‘C:\\PROGRA~1\\QGISWI~1\\apps\\qgis\\python\\plugins\\fTools\\tools’, ‘C:/Users/Jerry/Dropbox/_civicarchive/_client-user leads/david allen/civicsd/2014-2015 project lists/2014-15_map/gisData’]

  9. geosportsgeek said:

    I’m getting the following error message and QGIS crashes soon after I run the qgis2web plugin. Any help please?

    Crash dumped. minidump written to C: (file location).dmp

    • Please use the plugin bug tracker for support.

  10. Jake said:

    Did you ever solve these issues Tom? I’m having very similar problems. No preview, error messages if attempting a leaflet, I downloaded the plugin zip, If I attempt to export it anyway, it launches Internet Explorer (not my default browser) and Google Search Engine. Can’t find advice on QGIS pages!

  11. kuan said:

    Thanks Anita! This, coupled with QGIS server’s WMS functionality, enables a web mapping server for dummies like me.

    One more thing… If you use datasets directly in qgis2web, it’s basically saved as geojson and is quite slow when dataset is huge. So I load the data through WMS instead. However, in the wms mode, I could not click the features and see the attributes of the features. Would be great if that function can be implemented.

  12. joncfc said:

    Hello Tom. Have you put any restrictions your plugins use? I am looking at using it to display a few datasets (grass cutting initially) on my cash strapped local authorities website. I thought It would be a good idea to ask though before I do any further work with it though.

    Thanks

%d bloggers like this: