严格按照以下openlayers网站的示例进行操作:
https://openlayers.org/en/latest/examples/box-selection.html?q=feature
我在本地遇到以下错误:
Uncaught SyntaxError: Unexpected token <in JSON at position 0
at JSON.parse (<anonymous>)
at getObject (JSONFeature.js: 197)
at GeoJSON.JSONFeature.readFeatures (JSONFeature.js: 53)
at VectorSource. <anonymous> (featureloader.js: 94)
我认为该错误来自尝试在本地加载geojson文件。
var vectorSource = new VectorSource ({
url: 'data/geojson/countries.geojson', format: new GeoJSON ()
});
countries.geojson: https://r68tk.csb.app/data/geojson/countries.geojson
如何解决?