Files
openlayers/examples/lazy-source.js
Tim Schaub ad62739a6e Use blocked scoped variables
In addition to using const and let, this also upgrades our linter config and removes lint (mostly whitespace).
2018-01-12 00:50:30 -07:00

26 lines
528 B
JavaScript

import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js';
import TileLayer from '../src/ol/layer/Tile.js';
import OSM from '../src/ol/source/OSM.js';
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);
};