I want to load a local geojson to my map using openlayers.
Here is what I currently have:
var gjsonFile = new ol.layer.Vector({
source: new ol.source.Vector({
format: new ol.format.GeoJSON({
}),
url: './data/geojson/plan.geojson'
})
});
map.addLayer(gjsonFile);
But nothing is displayed, I get this error:
Uncaught SyntaxError: Unexpected token < in JSON at position 2
Anyone have a solution?
NB. i tried with this url: https://c.data.osmbuildings.org/0.2/anonymous/tile/15/17607/10743.json and it worked, so i have a problem with local paths.