To have the same path (starting with `ol/`, without `.js`) as in the documentation. The support was added in the webpack config in #8928
38 lines
819 B
JavaScript
38 lines
819 B
JavaScript
import Map from 'ol/Map';
|
|
import View from 'ol/View';
|
|
import GeoJSON from 'ol/format/GeoJSON';
|
|
import {defaults as defaultInteractions, Modify, Select} from 'ol/interaction';
|
|
import {Tile as TileLayer, Vector as VectorLayer} from 'ol/layer';
|
|
import {OSM, Vector as VectorSource} from 'ol/source';
|
|
|
|
|
|
const raster = new TileLayer({
|
|
source: new OSM()
|
|
});
|
|
|
|
const vector = new VectorLayer({
|
|
source: new VectorSource({
|
|
url: 'data/geojson/countries.geojson',
|
|
format: new GeoJSON(),
|
|
wrapX: false
|
|
})
|
|
});
|
|
|
|
const select = new Select({
|
|
wrapX: false
|
|
});
|
|
|
|
const modify = new Modify({
|
|
features: select.getFeatures()
|
|
});
|
|
|
|
const map = new Map({
|
|
interactions: defaultInteractions().extend([select, modify]),
|
|
layers: [raster, vector],
|
|
target: 'map',
|
|
view: new View({
|
|
center: [0, 0],
|
|
zoom: 2
|
|
})
|
|
});
|