I am new to OpenLayers and its awesome. Easy to get running when you do the quick setup. But now I am using OpenLayers and Node.
I have been following the setup with npm for OpenLayers and added all code from example from here. https://openlayers.org/en/latest/doc/tutorials/bundle.html
The imports I am using are these:
import 'ol/ol.css';
import {Map, View} from 'ol';
import TileLayer from 'ol/layer/Tile';
import OSM from 'ol/source/OSM';
Now when I am gonna use a function to read a local GeoJson file using Node to build it I get this error:
"Unable to get property 'GeoJSON' of undefined or null reference"
I am running this function to read my file.
function getData() {
return new ol.layer.Vector({
source: new ol.source.Vector({
//url: 'http://www.yourserver.com/static/test.geojson',
url: 'test.geojson',
format: new ol.format.GeoJSON()
})
});
}
What do I need to import for the function to work, or how do I rewrite it to work with Node.? Is there any more documentation because I guess I don't get how it works 100% Thanks for help
http://localhost/your-path/test.geojson- Mike