I have a problem loading external geojson file in OpenLayers 5.3.0 with the ol package. I installed it via npm. Here's the code:
import 'ol/ol.css';
import Map from 'ol/Map';
import View from 'ol/View';
import GeoJSON from 'ol/format/GeoJSON';
import {Tile as TileLayer, Vector as VectorLayer} from 'ol/layer';
import {OSM, Vector as VectorSource} from 'ol/source';
const map = new Map({
layers: [
new TileLayer({
source: new OSM()
}),
new VectorLayer({
source: new VectorSource({
url: 'data/geojson/countries.geojson',
format: new GeoJSON()
})
})
],
target: 'map',
view: new View({
center: [0, 0],
zoom: 2
})
});
The file does not show up on map. In console I receive an error 404(Not found)