Rendering raster data with WebGL.
This example uses WebGL to raster tiles on a map.
import Map from 'ol/Map.js';
import View from 'ol/View.js';
import Layer from 'ol/layer/WebGLTile.js';
import Source from 'ol/source/ImageTile.js';
const map = new Map({
target: 'map',
layers: [
new Layer({
source: new Source({
url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
attributions:
'© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors.',
}),
}),
],
view: new View({
center: [0, 0],
zoom: 0,
}),
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>WebGL Tiles</title>
<link rel="stylesheet" href="node_modules/ol/ol.css">
<style>
.map {
width: 100%;
height: 400px;
}
</style>
</head>
<body>
<div id="map" class="map"></div>
<script type="module" src="main.js"></script>
</body>
</html>
{
"name": "webgl-tiles",
"dependencies": {
"ol": "10.5.0"
},
"devDependencies": {
"vite": "^3.2.3"
},
"scripts": {
"start": "vite",
"build": "vite build"
}
}