完全按照以下 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 ()
});
country.geojson: https://r68tk.csb.app/data/geojson/countries.geojson
怎么解决?