Document SpreadsheetLayers and spin out Leaflet.SpreadsheetLayer as a stand-alone Leaflet library
jywarren opened this issue · 4 comments
@kevinzluo made a fantastic component for this library which really deserves to be its own Leaflet Plugin. Let's do it!
See a recent minimal Leaflet plugin I created here for reference: https://github.com/publiclab/leaflet-multispectral
Read more here: https://github.com/publiclab/leaflet-environmental-layers/blob/master/src/util/googleSpreadsheetLayer.js
We could make it in this repository: https://github.com/publiclab/leaflet-spreadsheet
I made a test spreadsheet here: https://docs.google.com/spreadsheets/d/14BvU3mEqvI8moLp0vANc7jeEvb0mnmYvH4I0GkwVsiU/edit#gid=0
Docs could be as follows, roughly:
### Spreadsheet-based layers
We can source locations from a spreadsheet in a format like this:
| Title | Latitude | Longitude | Notes |
|--------|----------|-------------|-------------------|
| First | 29.671282 | -95.17829 | The first marker |
| Second | 29.760371 | -95.504828 | The second marker |
| Third | 29.917755 | -95.283494 | The third marker |
The layer is constructed like this:
\```js
var layer = L.SpreadsheetLayer({
url: 'https://docs.google.com/spreadsheets/d/14BvU3mEqvI8moLp0vANc7jeEvb0mnmYvH4I0GkwVsiU/edit?usp=sharing', // String url of data sheet
lat: 'Latitude', // name of latitude column
lon: 'Longitude', // name of longitude column
columns: ['Title', 'Notes'], // Array of column names to be used
generatePopup: function() {
// function used to create content of popups
},
// imageOptions: // optional, defaults to blank
// sheetNum: // optional, defaults to 0 (first sheet)
});
layer.addTo(map);
\```
Read more here: https://github.com/publiclab/leaflet-environmental-layers/blob/master/src/util/googleSpreadsheetLayer.js
There are other libraries that do parts of this, but I still think this is an elegant and flexible implementation that's worth spinning out:
- https://github.com/jsoma/mapsheet
- https://github.com/veproza/moldova-mapping-with-spreadsheets
- https://github.com/mapsam/gus (good documentation on proper sharing of your spreadsheet)
- https://github.com/geraldo/driveMap
- https://github.com/banmedo/LeafletDigitizer
Note that I'm having trouble instantiating a new layer... not sure why it's not working. @kevinzluo why does this have to be a LayerGroup?
No issue @kevinzluo, we understand your situation and you are most welcome to contribute anytime, as per your convenience. Thanks!