I've followed several other posts but all the basic solutions have not worked. Basically, I can get it to show a GeoJSON correctly if I use a web link as the URL, but not a local file. For testing purposes, I will be using this GeoJSON file from OpenLayers, but the reason I need it to be a local file path is because I'm using a different GeoJSON file.
The following code works fine:
var vectorSource = new ol.source.Vector({
format: new ol.format.GeoJSON(),
url: 'https://openlayers.org/en/v4.6.4/examples/data/geojson/countries.geojson'
});
var vector = new ol.layer.Vector({
source: vectorSource,
});
But, when I save that file to a local path and try linking it, I get nothing to show on the map. I do know for sure that the path exists and is correct because I have other things in the same resource directory that load fine using the same path directory:
var vectorSource = new ol.source.Vector({
format: new ol.format.GeoJSON(),
url: '../resources/countries.geojson'
});
var vector = new ol.layer.Vector({
source: vectorSource,
});
What am I missing? I tried following the suggestion given here involving the IIS Manager but nothing has changed. I also tried changing the extension from .geojson to .js with no change also.
console.log
? the only reason I can guess is about accessing.geojson
file.