【发布时间】:2020-06-13 16:20:43
【问题描述】:
我正在尝试将 GeoJSON 文件导入到 react-leaflet,如下所示:
import * as bar from "./data/bar.geojson";
...
function Foo() {
return (
<Map center={[...]} zoom={...}>
<TileLayer
...
/>
<GeoJSON data={bar} />
</Map>
);
}
export default Foo;
我收到“错误:无效的 GeoJSON 对象”。拨打<GeoJSON data={bar} />。我将相同的 GeoJSON 数据硬编码到这个 javascript 文件中并且它工作正常,所以它一定是导致问题的导入或处理 GeoJSON 文件的方式。
有人知道我为什么会出错吗?提前致谢!
【问题讨论】:
标签: json reactjs leaflet geojson react-leaflet