To have the same path (starting with `ol/`, without `.js`) as in the documentation. The support was added in the webpack config in #8928
43 lines
1.0 KiB
JavaScript
43 lines
1.0 KiB
JavaScript
import Map from 'ol/Map';
|
|
import View from 'ol/View';
|
|
import {defaults as defaultControls, OverviewMap} from 'ol/control';
|
|
import {defaults as defaultInteractions, DragRotateAndZoom} from 'ol/interaction';
|
|
import TileLayer from 'ol/layer/Tile';
|
|
import OSM from 'ol/source/OSM';
|
|
|
|
|
|
const overviewMapControl = new OverviewMap({
|
|
// see in overviewmap-custom.html to see the custom CSS used
|
|
className: 'ol-overviewmap ol-custom-overviewmap',
|
|
layers: [
|
|
new TileLayer({
|
|
source: new OSM({
|
|
'url': 'https://{a-c}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png' +
|
|
'?apikey=0e6fc415256d4fbb9b5166a718591d71'
|
|
})
|
|
})
|
|
],
|
|
collapseLabel: '\u00BB',
|
|
label: '\u00AB',
|
|
collapsed: false
|
|
});
|
|
|
|
const map = new Map({
|
|
controls: defaultControls().extend([
|
|
overviewMapControl
|
|
]),
|
|
interactions: defaultInteractions().extend([
|
|
new DragRotateAndZoom()
|
|
]),
|
|
layers: [
|
|
new TileLayer({
|
|
source: new OSM()
|
|
})
|
|
],
|
|
target: 'map',
|
|
view: new View({
|
|
center: [500000, 6000000],
|
|
zoom: 7
|
|
})
|
|
});
|