From 45d51c35a9880946ce90c66999383e806f0b0b35 Mon Sep 17 00:00:00 2001 From: Florian Sommariva Date: Wed, 8 Dec 2021 18:09:13 +0100 Subject: [PATCH 1/2] Replace L.geoJson by L.geoJSON according to leaflet >1 --- README.md | 10 +++++----- src/leaflet.filelayer.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1cd285d..91703d9 100644 --- a/README.md +++ b/README.md @@ -34,12 +34,12 @@ Usage var map = L.map('map').fitWorld(); ... L.Control.fileLayerLoad({ - // Allows you to use a customized version of L.geoJson. + // Allows you to use a customized version of L.GeoJSON. // For example if you are using the Proj4Leaflet leaflet plugin, - // you can pass L.Proj.geoJson and load the files into the - // L.Proj.GeoJson instead of the L.geoJson. - layer: L.geoJson, - // See http://leafletjs.com/reference.html#geojson-options + // you can pass L.Proj.GeoJSON and load the files into the + // L.Proj.GeoJSON instead of the L.geoJSON. + layer: L.geoJSON, + // See https://leafletjs.com/reference.html#geojson layerOptions: {style: {color:'red'}}, // Add to map after loading (default: true) ? addToMap: true, diff --git a/src/leaflet.filelayer.js b/src/leaflet.filelayer.js index c164ffa..1b96ddc 100644 --- a/src/leaflet.filelayer.js +++ b/src/leaflet.filelayer.js @@ -41,7 +41,7 @@ }(function fileLoaderFactory(L, toGeoJSON) { var FileLoader = L.Layer.extend({ options: { - layer: L.geoJson, + layer: L.geoJSON, layerOptions: {}, fileSizeLimit: 1024 }, From f642efe41a9d5384d077b72fbc05db72d98b1176 Mon Sep 17 00:00:00 2001 From: Florian Sommariva Date: Wed, 8 Dec 2021 18:11:04 +0100 Subject: [PATCH 2/2] Use setData method to set current geoJSON --- src/leaflet.filelayer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/leaflet.filelayer.js b/src/leaflet.filelayer.js index 1b96ddc..c31dbbc 100644 --- a/src/leaflet.filelayer.js +++ b/src/leaflet.filelayer.js @@ -198,7 +198,7 @@ if (typeof content === 'string') { content = JSON.parse(content); } - layer = this.options.layer(content, this.options.layerOptions); + layer = this.options.layer.addData(content, this.options.layerOptions); if (layer.getLayers().length === 0) { throw new Error('GeoJSON has no valid layers.');