-
Notifications
You must be signed in to change notification settings - Fork 78
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
Script for generating new spreadsheet based layers #528
Comments
Thanks for opening your first issue! This space is protected by our Code of Conduct - and we're here to help. |
Can you please review the checklist once? |
Hi, my thoughts were to put everything in the same repo, maybe in a /scripts/ folder? How does that sound? We can put a README in there too, just README.md should appear in GitHub in a directory. |
I came up with a much more cleaner way to import stuff const fs = require("fs");
// List all json files in the driectory containing spreadsheet based layer
const layerFiles = fs
.readdirSync("./")
.filter((file) => file.endsWith(".json"));
for (const file of layerFiles) {
// Dynamically import the listed file
const data = fs.readFileSync(__dirname + `/${file}`, "utf8");
const layerData = JSON.parse(data);
//Evaluate based on dynamic data
let newLayer = function (options) {
return new L.SpreadsheetLayer({
url: layerData.url,
lat: "Latitude",
lon: "Longitude",
generatePopup: function () {},
imageOptions: {
icon: L.icon.mapKnitterIcon(),
},
});
};
eval("L.layerGroup." + layerData.name + "=newLayer");
} |
I am not sure about how to transpile this for browsers. I found about https://github.com/browserify/brfs/ which would compile |
I think I was only trying to read multiple json files since I was trying to have all the layers have there respective json files. But that's not a necessity 🤔 |
Ooh!!! Very nice! Couldn't we run this during compilation so it doesn't need to transpile? The /dist/ versions would then include all of this? Very cool @daemon1024 -- i like it a lot! Want to try opening a PR with this and slowly build on it? |
Noting some of the things which needs to be handled in the subsequent pull requests.
|
Regarding OneLinerCodeExample we are using https://github.com/publiclab/leaflet-environmental-layers/blob/main/src/AllLayers.js I think we will need to modify how the source of truth for the layer names work. Currently it's hardcoded but we need to extract it from info.json maybe. But I am not sure hwo the layer group works. |
Initial Steps for #488
Aim of the script is to generate a new spreadsheet layer based on some configuration ( json for now ).
Checklist the script should perform:
src/layername.js
with the following contentAllLayers.js
LeafletEnvironmentalLayers.js
Ref publiclab/plots2#9698
The text was updated successfully, but these errors were encountered: