Declaring the local file
tardigrde opened this issue · 1 comments
tardigrde commented
Where do I declare which file to load as a layer?
So I don't see a part of code in the usage where I can declare that I want to display this and this .geojson as a map layer.. Can somebody help?
leplatrem commented
This plugin is not meant to load one your files to everyone visiting your map.
Instead it allows users to browse their local files and load them on their map.
To load one of your files to the map, you don't need this plugin. Something like that (totally untested) would be enough:
fetch('yourgeojson.json')
.then(resp => resp.json())
.then(data => {
L.geoJSON(data).addTo(map);
})
or with modern JavaScript:
async function loadGeoJSON(map) {
const resp = await fetch('yourgeojson.json');
const data = await resp.json()
L.geoJSON(data).addTo(map);
}