I'm trying to create a "Hello World" OpenLayers map, with no unnecessary dependencies. The code is

<html> <head><meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="./resources/ol.css"> <title>OpenLayers3 scratchpad</title></head> <body> <noscript><h4>Javascript is not enabled in your browser and this map will not not work.</h4></noscript> <div id="mapdiv"> <script src="./resources/ol.js"> import Map from 'ol/Map.js'; import View from 'ol/View.js'; import TileLayer from 'ol/layer/Tile.js'; import OSM from 'ol/source/OSM.js'; const map = new Map({ view: new View({ center: [-0.2262, 51.5403], zoom: 12, }), layers: [ new TileLayer({ source: new OSM(), }), ], target: 'map', }); </script> </div> </body></html>

All paths exist, all GETs succeed, there are no webserver or browser console errors - and no map, just an empty screen. Do I have to have node.js?

adrianhb's user avatar

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.