1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| import Map from 'ol/Map.js'; import TileLayer from 'ol/layer/Tile.js'; import TileWMS from 'ol/source/TileWMS.js'; import View from 'ol/View.js'; import {ScaleLine, defaults as defaultControls} from 'ol/control.js';
const layers = [ new TileLayer({ source: new TileWMS({ url: 'https://ahocevar.com/geoserver/wms', params: { 'LAYERS': 'ne:NE1_HR_LC_SR_W_DR', 'TILED': true, }, }), }), ];
const map = new Map({ controls: defaultControls().extend([ new ScaleLine({ units: 'degrees', }), ]), layers: layers, target: 'map', view: new View({ projection: 'EPSG:4326', center: [0, 0], zoom: 2, }), });
|