I want simple OSM map to show up with the new version. Got everything finally working just to get an error in consol stating:
Uncaught TypeError: Failed to resolve module specifier “rbush”. Relative references must start with either “/”, “./”, or “../”.
I got 4 files that are involved in this: base.html, map.html, style.css and script.js
base.html
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
crossorigin="anonymous"
/>
<title>{% block title %}Home{% endblock %}</title>
<link rel="icon" href="static/Icon/4545.ico" type="image/x-icon">
<link rel="stylesheet" href="static/style.css"/>
<link rel="stylesheet" href="static/ol.css"/>
</head>
<body>
<div class="container">
{% block content %}
{% endblock %}
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
crossorigin="anonymous">
</script>
<script src="static/index.js"></script>
<script type="module" src="static/script.js"></script>
</body>
map.html
{% extends "base.html" %}
<title>{% block title %}Map{% endblock %}</title>
{% block content %}
<p>TEST Map</p>
<div id="map"></div>
{% endblock %}
style.css
#map {
position: absolute;
width: 100%;
height: 400px;
}
script.js
import Map from '/static/ol_10/Map.js';
import OSM from '/static/ol_10/source/OSM.js';
import TileLayer from '/static/ol_10/layer/Tile.js';
import View from '/static/ol_10/View.js';
const map = new Map({
target: 'map',
layers: [
new TileLayer({
source: new OSM(),
}),
],
view: new View({
center: [0, 0],
zoom: 2,
}),
});
Could use some Build Tool to fix thats not really that big of a problem. I just wanna know if someone is experiencing the same problem?
Jan Truneček is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.