Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

315
Visualizações
How to load and use modules in embedded JavaScript (EJS) code

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:

  • https://github.com/geotiff/georaster-layer-for-leaflet

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.

about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda