So I made a weathermap with GeoServer and OpenLayers5.

Works fine and all, but NodeJS keeps giving me a hard time. Does anybody know how this really works?

Because I need input from the end-user, but NodeJS doesn't understand that. I need to be able to put in a date and update my WMS params so that I can show different types of weather (call different kind of layer groups from GeoServer). What the OL5 setup tells me to do is this: https://openlayers.org/en/latest/doc/tutorials/bundle.html. (NodeJS with NPM and Parcel/Make an index.html and index.js/Create a bundle/I can develop using NPM start/To create a production bundle I only have to 'npm run build' and then copy those dist files to my production server.) Seems easy enough. I did all the steps, and indeed I can now show a map with my GeoServer layers.

But what I CANNOT do is make a function in my JavaScript and use that for my user-input. Whenever I put a function in my index.js and want to use it in my HTML it tells me that it is not defined.

I asked a sort similar question on Stack Overflow and they directed me to Express. And I spend my whole morning watching tutorials on Express, but I do think it should not have to be this difficult. Especially since OL5 setup guide does not talk about any of that. Who can help me?

  • This is what I want to achieve: gis.stackexchange.com/questions/307917/… – Trisha Jan 8 at 12:44
  • What if you use document.querySelector('input').onclick = function ... in your Javascript (e.g. define what happens at the onclick event inside the JS)? – Stefan Jan 9 at 18:31
  • I don't think that works in NodeJS. I have tried it, but I can't seem to make it work. – Trisha Jan 10 at 9:10
  • Can you show us some code? It's quite hard to tell what you're trying to do and how you want to use these functions (events?). – dmh126 Feb 7 at 12:21
  • I already fixed it. Do not use NPM anymore, but decided to just use the github script instead of having OL local. – Trisha Feb 7 at 12:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.