Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declaring the local file #55

Open
tardigrde opened this issue Jan 10, 2018 · 1 comment
Open

Declaring the local file #55

tardigrde opened this issue Jan 10, 2018 · 1 comment

Comments

@tardigrde
Copy link

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
Copy link
Collaborator

leplatrem commented Jan 11, 2018

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);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants