Files
openlayers/examples/lazy-source.js
Frederic Junod 79c8afdba8 Simplify import path in examples
To have the same path (starting with `ol/`, without `.js`) as in the documentation.
The support was added in the webpack config in #8928
2018-11-26 17:18:52 +01:00

26 lines
488 B
JavaScript

import Map from 'ol/Map';
import View from 'ol/View';
import TileLayer from 'ol/layer/Tile';
import OSM from 'ol/source/OSM';
const source = new OSM();
const layer = new TileLayer();
const map = new Map({
layers: [layer],
target: 'map',
view: new View({
center: [0, 0],
zoom: 2
})
});
document.getElementById('set-source').onclick = function() {
layer.setSource(source);
};
document.getElementById('unset-source').onclick = function() {
layer.setSource(null);
};