Closed kkdd closed 8 years ago
I tried it and it works as expected :) What kind of errors do you have?
Thank you for your comment. My failure was cause by a syntax error in parsing json due to the strictness of JSON.parse(). In order to relax the situation, I would like to modify the source as follows:
+ try
+ {
- content = JSON.parse(content);
+ content = eval("(" + content + ")");
+ }
+ catch(e)
+ {
+ console.log("in parsing json: SyntaxError");
+ }
and additionally
this._parsers = {
'geojson': this._loadGeoJSON,
+ 'json': this._loadGeoJSON,
'gpx': this._convertToGeoJSON,
'kml': this._convertToGeoJSON
};
.
I don't feel entirely at ease with eval()
... Can you argue a bit more please ? Would it go here https://github.com/makinacorpus/Leaflet.FileLayer/blob/gh-pages/leaflet.filelayer.js#L64 ?
But I'm ok with considering .json
extension as GeoJSON. You can open a pull-request ! (or just edit the file directly on Github if it's easier for you)
Thanks !
Hello, I have realized that the demo, http://makinacorpus.github.io/Leaflet.FileLayer/index.html, doesn't work for geojson files, but for kml files. ps. I would appreciate it if you could put some sample files in the Leaflet.FileLayer directory.