My current scripts/codes flow is index.js->routes.js->main.ejs
I need to load a GeoTiff-related module and use its plotting functions in my main.ejs
. However I find that ejs
does not support loading modules within the code, so I need to load the GeoTiff modules in my index.js
or routes.js
and render the functions to main.ejs
.
I found some examples from Google and followed their methods but unfortunately I couldn't make it work. The error information keeps showing that the GeoTiff-related functions in main.ejs are not defined
.
The github website of the module I try to use is here:
As you can see in the Usage Example it directly require
the georaster and then compose the plot functions in the same js code, whereas in my case my plot codes will be in my main.ejs
where I can not require
the georaster directly.
Following the method in this page:
https://rajuthapa-13222.medium.com/how-to-use-node-packages-on-ejs-html-templating-engine-d51885e91deb
I tried the following codes in my routes.js
var parse_georaster = require("georaster");
var GeoRasterLayer = require("georaster-layer-for-leaflet");
var getMain = function (req, res) {
res.render('main',{parse_georaster: parse_georaster,GeoRasterLayer: GeoRasterLayer});
};
But it seems not working. I still can not use the function of parse_georaster
and GeoRasterLayer
in my main.ejs
.