Geolicious / qgis2leaf

A QGIS plugin to create a working leaflet based webmap from it
127 stars 30 forks source link

Export as true .geojson, load with AJAX plugin #240

Open reyemtm opened 9 years ago

reyemtm commented 9 years ago

Forgive me if this has already been addressed, but I couldn't find it anywhere.

I love the plugin but it creates js files that are not true geojson files in that to use them again in qgis or some other software, you would have to rename them and edit them to take out the var parameter:

var exp_btrail = {
"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, 

This also means that data that is already published online cannot be linked to for download. It would be great if there could be an option for, or just switch to as a default, exporting .geojson files. They could then be loaded with something like the geojson ajax plugin here.

Also, for points, they could just be exported as .csv files, as there is really no need for these to be in a true spatial format. For very large datasets I have heard that csv files load faster but have not verified this.

tomchadwin commented 9 years ago

The exported files are JSONP, not JSON. This is commonly used so that remote data can be used in compliance with the same origin policy.

Can you explain further what you mean by "data that is already published online cannot be linked to for download"? If the data is being served by WFS, then it can be included, as long as the remote server can serve JSONP. If not, and the data is just static JSON, then browsers would not allow loading of it from a remote location. That is the reason JSONP was created, and is normally used.

Would you mind opening another issue for the CSV request?

reyemtm commented 9 years ago

The way the plugin is set up now, it is all served/linked as if it's on the same domain so I am not sure why there is a need to get around remote reources. Regardless it would be nice to have the option of exporting as .geojson, eventhough you are right in that the geojson would likely not load if the data folder was moved and hosted on a separate domain.

It would just be nice to have the file being mapped via leaflet be able to be downloaded and viewed in desktop gis software as is.

tomchadwin commented 9 years ago

Using JSONP means that users have the option to host the files elsewhere, and everything will still work. This would not be the case with unpadded JSON. However, your argument does have merit.