0

I made a map in QGIS and exported it to .html with the QGIS2web-plugin. The html-code will be used to place an interactive map in our website. It works perfectly.

Nevertheless, I was wondering how to update my data. I can update my map in my QGIS Client and export it all over again to the website, by exporting the map via the plugin again and copying the HTML-code in our website. But is there another way to just update the existing exported webmap? Let say if I overwrite the map structure that is exported via the plugin, will my webmap automatically be updated if I use the same/original file names? Or is a new export always required?

0

3 Answers 3

1

If you look into the structure generated by qgis2web you can try and find out where the data is stored.

For example I just made a simple OpenLayers web map with a single point layer.

This had subfolders called images, layers, resources, styles, and webfonts.

Within "layers", there was "Newscratchlayer_1.js" which is JS code that creates an object from some inline GeoJSON...

var json_Newscratchlayer_1 = {"type":"FeatureCollection","name":"Newscratchlayer_1","crs":{"type":"nam....

etc. And that is the three points in my data layer.

At a guess I'd say if you changed that file then the map would change. You just have to prepend var json_Newscratchlayer_1 = to your data as GeoJSON and shazam.

Of course it might not work as simply as that - I don't know if the number of points, or the extent of the layer etc is encoded elsewhere in the output. But for simple data updates it might work. Adding another layer wouldn't be as simple - it would require tweaking at least layers.js in that folder and who knows what else too.

Note this is as I see a very simple web map with the OpenLayers option - it might be different for Leaflet etc. Looking at a Leaflet export from qgis2web it seems layers are defined similarly in the data subfolder.

0
1

I did a test with a leaflet export.

The data subfolder of your export contains the data files.

You can perform a new export and only copy the new data files to the web server in the old directory structure.

This will only work if the legend does not change between exports!

0
1

qgis2web export creates an index.html file that retrieves system files and data.

If you add geometry to the layers already exported you just overwrite the data folder, but if you add fields to the layers you will have to overwrite everything, the same thing applies if you add new layers. Therefore, since in any case you have to copy/paste it, you are advised to always overwrite everything.

As they have already answered you, it is possible to automate everything with ftp directly from the qgis2web plugin, Export tab, exporter choice.

An important tip: All exporting generates a static site that when visited downloads data to the local PC that visits it, so you may find yourself in a position to update your map, visit the website where you have placed it, and see old data, because the browser will load those in its cache for all files with the same name. To work around add these lines in the head of your index.html file

<meta http-equiv='cache-control' content='no-cache'>
<meta http-equiv='expires' content='0'>
<meta http-equiv='pragma' content='no-cache'>

Thus the browser will be instructed to always take files from the site and not from its own cache.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.